[ENG-512] Fix empty explorer view (#741)

Fix initial render
This commit is contained in:
nikec 2023-04-21 16:31:05 +02:00 committed by GitHub
parent d519af6448
commit d8aa70cca4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View file

@ -102,7 +102,7 @@ export default () => {
}
// Resize view on initial render
useLayoutEffect(() => handleWindowResize(), []);
useEffect(() => handleWindowResize(), []);
// Resize view on window resize
useOnWindowResize(handleWindowResize);

View file

@ -70,6 +70,7 @@ export default () => {
const { data, scrollRef } = useExplorerView();
const { isScrolled } = useScrolled(scrollRef, 5);
const [sized, setSized] = useState(false);
const [columnSizing, setColumnSizing] = useState<ColumnSizingState>({});
const [locked, setLocked] = useState(true);
const [lastSelectedIndex, setLastSelectedIndex] = useState<number>(
@ -207,7 +208,7 @@ export default () => {
}
// Measure initial column widths
useLayoutEffect(() => {
useEffect(() => {
if (scrollRef.current) {
const columns = table.getAllColumns();
const sizings = columns.reduce(
@ -219,6 +220,7 @@ export default () => {
const sizingsSum = Object.values(sizings).reduce((a, b) => a + b, 0);
const nameWidth = scrollWidth - paddingX * 2 - scrollBarWidth - sizingsSum;
table.setColumnSizing({ ...sizings, Name: nameWidth });
setSized(true);
}
}, []);
@ -285,6 +287,7 @@ export default () => {
{ when: !explorerStore.isRenaming }
);
if (!sized) return null;
return (
<div role="table" className="table w-full overflow-x-auto">
<div

View file

@ -107,7 +107,7 @@ export default () => {
}
// Resize view on initial render
useLayoutEffect(() => handleWindowResize(), []);
useEffect(() => handleWindowResize(), []);
// Resize view on window resize
useOnWindowResize(handleWindowResize);