fix(List): Fix scroll to highlighted component with keyboard navigation #145
Merged
igorarkhipenko merged 11 commits intomasterfrom Jul 25, 2019
Merged
fix(List): Fix scroll to highlighted component with keyboard navigation #145igorarkhipenko merged 11 commits intomasterfrom
igorarkhipenko merged 11 commits intomasterfrom
Conversation
eszthoff
approved these changes
Jul 24, 2019
antipin
suggested changes
Jul 24, 2019
src/components/List/List.js
Outdated
|
|
||
| // Scroll view with a delay so this function would refer to the next highlighted item | ||
| setTimeout(() => { | ||
| highlightedListItem.current.scrollIntoView(SCROLL_INTO_VIEW_SETTINGS); |
Contributor
There was a problem hiding this comment.
-
IE11 doesn't support scrollIntoView :(
-
What if component was unmounted before this timeout is executed?
Contributor
Author
There was a problem hiding this comment.
- Yeah, that's a pity, it doesn't get
SCROLL_INTO_VIEW_SETTINGSparam but the scroll by itself is still working so we decided to stick with that. - I'll add
clearTimeoutfunction call before unmounting to be sure it never happens
antipin
reviewed
Jul 25, 2019
src/components/List/List.js
Outdated
| } | ||
| }, [selectedIndex]); | ||
|
|
||
| const getNextSelectedIndex = keyCode => { |
Contributor
There was a problem hiding this comment.
Looks good. But I've just noticed that all the event handlers in this component are being recreated on every render, which is not efficient. Could you wrap them into useCallback in order to memoize it?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.