fix: scroll to correct focused row on keyboard navigation#8003
Conversation
| const targetRowInDom = [...this.$.items.children].find((child) => child.index === index); | ||
| if (!targetRowInDom) { | ||
| this.scrollToIndex(index); | ||
| this._scrollToFlatIndex(index); |
There was a problem hiding this comment.
note: We forgot to update __ensureFlatIndexInViewport after we changed the signature of scrollToIndex to support scrolling to hierarchical indexes.
|
|
||
| // Ensure the correct element is set as focusable after scrolling. | ||
| // The virtualizer may use a different element to render the item. | ||
| this.__updateItemsFocusable(); |
There was a problem hiding this comment.
note: The previous version didn't update the focusable element if it was a row, which often resulted in a wrong row getting focused.
| // Let's use a count lower than pageSize so we can ignore page + pageSize for now | ||
| const itemsOnEachLevel = 5; | ||
| const itemsOnEachLevel = 100; |
There was a problem hiding this comment.
nit: This is no longer lower than page size so the comment does not apply anymore (and the data provider should be updated to take page + pageSize into account).
There was a problem hiding this comment.
Oh, good catch! I completely forgot to add pagination now that the size has increased. Fixed.
|
|
Hi @vursen and @vursen, when i performed cherry-pick to this commit to 24.5, i have encountered the following issue. Can you take a look and pick it manually? |
|
Hi @vursen and @vursen, when i performed cherry-pick to this commit to 24.4, i have encountered the following issue. Can you take a look and pick it manually? |



Description
Fixes the regression where keyboard navigation could cause the grid to scroll to and focus a wrong row, especially when some items were expanded.
Fixes #7991
Type of change