Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
- `NavigatorScreen`: fix focus issue where back button received focus unexpectedly ([#44239](https://github.com/WordPress/gutenberg/pull/44239))
- `FontSizePicker`: Fix header order in RTL languages ([#44590](https://github.com/WordPress/gutenberg/pull/44590)).

### Enhancements

- `SuggestionList`: use `requestAnimationFrame` instead of `setTimeout` when scrolling selected item into view. This change improves the responsiveness of the `ComboboxControl` and `FormTokenField` components when rapidly hovering over the suggestion items in the list ([#44573](https://github.com/WordPress/gutenberg/pull/44573)).

### Internal

- `Mobile` updated to ignore `react/exhaustive-deps` eslint rule ([#44207](https://github.com/WordPress/gutenberg/pull/44207)).
Expand Down
10 changes: 5 additions & 5 deletions packages/components/src/form-token-field/suggestions-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function SuggestionsList< T extends string | { value: string } >( {
( listNode ) => {
// only have to worry about scrolling selected suggestion into view
// when already expanded.
let id: number;
let rafId: number | undefined;
if (
selectedIndex > -1 &&
scrollIntoView &&
Expand All @@ -52,14 +52,14 @@ export function SuggestionsList< T extends string | { value: string } >( {
onlyScrollIfNeeded: true,
}
);
id = window.setTimeout( () => {
rafId = requestAnimationFrame( () => {
setScrollingIntoView( false );
}, 100 );
} );
}

return () => {
if ( id !== undefined ) {
window.clearTimeout( id );
if ( rafId !== undefined ) {
cancelAnimationFrame( rafId );
}
};
},
Expand Down