Retain list row focus when scrolling#15641
Merged
niik merged 2 commits intodevelopmentfrom Dec 2, 2022
Merged
Conversation
Turns out e11038a introduced a regression where the intention was changed from "selection not included" to "selection included"
Moves focus away from unmounted list items to the grid such that keyboard navigation still works after scrolling Co-Authored-By: Mark Hicken <849930+markhicken@users.noreply.github.com>
tidy-dev
approved these changes
Nov 18, 2022
Contributor
tidy-dev
left a comment
There was a problem hiding this comment.
✨ Works great! Awesome that it keeps the keyboard navigation. :)
Contributor
|
👍🏼 Yes! Very nice @niik! I tested on Mac and Windows, but didn't have a Linux machine to test on. |
This comment was marked as off-topic.
This comment was marked as off-topic.
sergiou87
reviewed
Nov 24, 2022
| this.props.onSelectionChanged | ||
| ) { | ||
| this.props.onSelectionChanged([row], { kind: 'hover', event }) | ||
| if (!this.props.selectedRows.includes(row)) { |
Member
There was a problem hiding this comment.
I was wondering about this ! change until I remembered e11038a 😳
Leaving it here for reference in case someone else wonders!
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.
Closes #2957
Description
While scrolling in our virtualized lists items get unmounted and recreated constantly. For the most part this works well but if the user has focused a list item the focus reverts back to the body when the element is unmounted. I could have sworn it used to be that it reverted to the closest focusable ancestor and that's why we made it so that list items are styled as if they selected+focused as long as the list component has focus anywhere inside of it but something somewhere sure has changed.
In #15604 @markhicken did some great work which resolved the selection issue but the issue with keyboard focus being reset to the body element (as long as the selected item was out of view) remained. In this PR I'm attempting to fix both issues by explicitly detecting when the selected+focused item is unmounted and moving the focus to the List component (instead of body). This lets keyboard selection continue to work even though the selected list item has been unmounted.
Screenshots
Release notes
Notes: [Fixed] Ensure selected list items stay selected when scrolling