-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(stickyTree): hidden item + focus loss could happen when the last …
…sticky header is collapsed (#16341) #### Pull request checklist - [ ] Addresses an existing issue: Fixes #0000 - [ ] Include a change request file using `$ yarn change` #### Description of changes Fixing 2 focus related issues in sticky tree: ### issue 1: when navigate using keyboard, item can be hidden behind sticky header - before the fix: ![image](http://g.recordit.co/EbMtKgXykK.gif) - after: ![image](http://g.recordit.co/xynV3iSANR.gif) ### issue 2: focus lost when the entire list is scrolled to the top, and the last sticky header is clicked. React profiler shows that, when the focus loss happens, the sticky header component is recreated, instead of updated. This is because: the sticky header is created by `createTreeItem`, which came from the prop of the 1st children in the virtual list. But the 1st children in the virtual list can be undefined, causing the rendered list to be null, and sticky header was unmounted. Why the 1st children can be undefined: react-window uses startIndex/stopIndex to render visible items (children of list). When an item collapsed, the number of total items changes, causing the 'stopIndex' to be smaller than 'startIndex' during re-rendering, which result in the `children[0]` being undefined. The fix is to pass a stable `createTreeItem` thru context, which always renders sticky headers, so they don't get unmounted. - before the fix, when the last sticky header was clicked, focus lost to the entire list: ![image](http://g.recordit.co/y6CnxUAeWR.gif) - after: ![image](http://g.recordit.co/ApWkGtIxhm.gif) #### Focus areas to test (optional)
- Loading branch information
1 parent
5902550
commit 62d455a
Showing
2 changed files
with
57 additions
and
29 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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