fix: GroupedList.scrollToIndex() now targets group index#29173
Closed
spmonahan wants to merge 1 commit into
Closed
fix: GroupedList.scrollToIndex() now targets group index#29173spmonahan wants to merge 1 commit into
spmonahan wants to merge 1 commit into
Conversation
scrollToIndex accepts an item index value which, for a flat List is the row index in the List. Because GroupedList is a List of Lists the item index does not necessarily correspond with the row index in the List. In fact, the first level of the List only has items for the number of groups in the List so in most cases the scroll to index will be out of bounds so far as the List is concerned and therefore will not be found. This change remaps "item index" to "group index" in GroupedLists scrollToIndex() method which should ensure the group that owns an particular row is scrolled in to view. Note: this issue does not affect GroupedListV2 as it is implemented as a flat List under the hood.
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 51d8ffd:
|
khmakoto
approved these changes
Sep 18, 2023
Collaborator
🕵 fluentuiv8 No visual regressions between this PR and main |
Collaborator
📊 Bundle size report🤖 This report was generated against 6840cead921e4d30772dd9ab2cd234fe26a690f4 |
Asset size changes
Baseline commit: 6840cead921e4d30772dd9ab2cd234fe26a690f4 (build) |
Collaborator
Perf Analysis (
|
| Scenario | Render type | Master Ticks | PR Ticks | Iterations | Status |
|---|---|---|---|---|---|
| BaseButton | mount | 627 | 626 | 5000 | |
| Breadcrumb | mount | 1665 | 1667 | 1000 | |
| Checkbox | mount | 1671 | 1692 | 5000 | |
| CheckboxBase | mount | 1443 | 1449 | 5000 | |
| ChoiceGroup | mount | 2980 | 2881 | 5000 | |
| ComboBox | mount | 649 | 637 | 1000 | |
| CommandBar | mount | 6145 | 6123 | 1000 | |
| ContextualMenu | mount | 12408 | 12397 | 1000 | |
| DefaultButton | mount | 755 | 761 | 5000 | |
| DetailsRow | mount | 2151 | 2167 | 5000 | |
| DetailsRowFast | mount | 2134 | 2126 | 5000 | |
| DetailsRowNoStyles | mount | 1973 | 1983 | 5000 | |
| Dialog | mount | 2589 | 2785 | 1000 | |
| DocumentCardTitle | mount | 242 | 229 | 1000 | |
| Dropdown | mount | 1981 | 1981 | 5000 | |
| FocusTrapZone | mount | 1117 | 1153 | 5000 | |
| FocusZone | mount | 1052 | 1093 | 5000 | |
| GroupedList | mount | 41116 | 41254 | 2 | |
| GroupedList | virtual-rerender | 19789 | 19692 | 2 | |
| GroupedList | virtual-rerender-with-unmount | 50154 | 50238 | 2 | |
| GroupedListV2 | mount | 233 | 227 | 2 | |
| GroupedListV2 | virtual-rerender | 221 | 215 | 2 | |
| GroupedListV2 | virtual-rerender-with-unmount | 218 | 220 | 2 | |
| IconButton | mount | 1082 | 1074 | 5000 | |
| Label | mount | 329 | 327 | 5000 | |
| Layer | mount | 2674 | 2664 | 5000 | |
| Link | mount | 387 | 380 | 5000 | |
| MenuButton | mount | 923 | 934 | 5000 | |
| MessageBar | mount | 21286 | 21255 | 5000 | |
| Nav | mount | 1903 | 1944 | 1000 | |
| OverflowSet | mount | 770 | 775 | 5000 | |
| Panel | mount | 1773 | 1763 | 1000 | |
| Persona | mount | 724 | 759 | 1000 | |
| Pivot | mount | 869 | 848 | 1000 | |
| PrimaryButton | mount | 823 | 827 | 5000 | |
| Rating | mount | 4490 | 4592 | 5000 | |
| SearchBox | mount | 885 | 886 | 5000 | |
| Shimmer | mount | 1846 | 1815 | 5000 | |
| Slider | mount | 1310 | 1265 | 5000 | |
| SpinButton | mount | 2869 | 2864 | 5000 | |
| Spinner | mount | 385 | 377 | 5000 | |
| SplitButton | mount | 1765 | 1792 | 5000 | |
| Stack | mount | 388 | 410 | 5000 | |
| StackWithIntrinsicChildren | mount | 845 | 835 | 5000 | |
| StackWithTextChildren | mount | 2583 | 2586 | 5000 | |
| SwatchColorPicker | mount | 6039 | 6162 | 5000 | |
| TagPicker | mount | 1429 | 1456 | 5000 | |
| Text | mount | 362 | 371 | 5000 | |
| TextField | mount | 938 | 920 | 5000 | |
| ThemeProvider | mount | 820 | 820 | 5000 | |
| ThemeProvider | virtual-rerender | 573 | 579 | 5000 | |
| ThemeProvider | virtual-rerender-with-unmount | 1260 | 1269 | 5000 | |
| Toggle | mount | 603 | 632 | 5000 | |
| buttonNative | mount | 191 | 192 | 5000 |
Contributor
Author
|
Closing this in favor of #29332. |
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.
Previous Behavior
scrollToIndex()for aGroupedList(or groupedDetailsList--GroupedListis used under the hood in this scenario) does not always scroll to the provided index.New Behavior
scrollToIndex()now works.The reason this did not work is that
GroupedListis actuallyListofLists and internally it maintains two lists:itemsa flat list of itemsgroupsa nested list of groups thatitemsis projected intoIn
GroupedListthe rootList, which is the list thatscrollToIndex()is called only hasgroups.lengthitems in it (wheregroups.lengthis the number of root level groups) and in many (most?) casesitems.length > groups.length. When this is the case any item index> groups.lengthis out of bounds and the list is not scrolled because the item in question cannot be found.This is an example of
scrollToIndexworking becauseitems.length < groups.length.This change updates the
scrollToIndex()implementation inGroupedListto map the providedindexback to a group index which is guaranteed to be in bounds since this method is only called on the root list in aGroupedList.NOTE: this issue does not affect
GroupedListV2as that is implemented as a flat list.A similar API,
focusIndex()does not exhibit this problem. The reason for this is that it looks up the item in question and callsfocus()on it which triggers the browser to bring the element in to view.Related Issue(s)
scrollToIndex()#29169