Skip to content

Commit b1569d7

Browse files
authored
Make the auto scroll code run again
`<SuggestionsOverlay>` was converted to hooks and the code which handles scrolling to the (keyboard) selected suggestion item was moved from `componentDidUpdate` to a `useEffect` with an empty dependency array causing it to run only on mount instead of on every state change. Removing the dependency array completely would bring back the original behavior but running just when `focusIndex` is often enough, so that has now been added to the (previously empty) dependency array.
1 parent e1009e3 commit b1569d7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/SuggestionsOverlay.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function SuggestionsOverlay({
5050
} else if (bottom > ulElement.offsetHeight) {
5151
ulElement.scrollTop = bottom - ulElement.offsetHeight
5252
}
53-
}, [])
53+
}, [focusIndex])
5454

5555
const renderSuggestions = () => {
5656
const suggestionsToRender = Object.values(suggestions).reduce(

0 commit comments

Comments
 (0)