Skip to content

Commit

Permalink
update snapshot, tune windowOverscan to 40 instead of visibleitems
Browse files Browse the repository at this point in the history
  • Loading branch information
gwwar committed Oct 28, 2021
1 parent 0113349 commit 96a183f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports[`BlockSwitcherDropdownMenu should render disabled block switcher with mu
className="block-editor-block-switcher__no-switcher-icon"
disabled={true}
icon={
<BlockIcon
<Memo(BlockIcon)
icon={
<SVG
viewBox="0 0 24 24"
Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/src/components/list-view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ function ListView(
visibleBlockCount,
{
useWindowing: __experimentalPersistentListViewFeatures,
windowOverscan: 40,
}
);

Expand Down
11 changes: 8 additions & 3 deletions packages/compose/src/hooks/use-fixed-window-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,19 @@ export default function useFixedWindowList(
return;
}
const scrollContainer = getScrollContainer( elementRef.current );
const measureWindow = () => {
const measureWindow = (
/** @type {boolean | undefined} */ initRender
) => {
if ( ! scrollContainer ) {
return;
}
const visibleItems = Math.ceil(
scrollContainer.clientHeight / itemHeight
);
const windowOverscan = options?.windowOverscan ?? visibleItems;
// Aim to keep opening list view fast, afterward we can optimize for scrolling
const windowOverscan = initRender
? visibleItems
: options?.windowOverscan ?? visibleItems;
const firstViewableIndex = Math.floor(
scrollContainer.scrollTop / itemHeight
);
Expand Down Expand Up @@ -96,7 +101,7 @@ export default function useFixedWindowList(
} );
};

measureWindow();
measureWindow( true );
const debounceMeasureList = debounce( () => {
measureWindow();
}, 16 );
Expand Down

0 comments on commit 96a183f

Please sign in to comment.