-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add and remove focused-cell part when scrolling grid #7659
Conversation
@@ -855,6 +856,16 @@ export const GridMixin = (superClass) => | |||
this._getItem(index, row); | |||
} | |||
|
|||
/** @private */ | |||
_updateFocusedItem(row) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_updateFocusedItem(row) { | |
__updateFocusedItem(row) { |
We wanted to start using double underscores for private methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const focusedItemInRow = row.__virtualIndex === this._focusedItemIndex; | ||
let isFocusedCell; | ||
iterateChildren(row, (cell) => { | ||
isFocusedCell = cell === this._focusedCell; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this comparison is safe to use with the virtual scrolling mechanism. If you scroll down and up again, is the cell in the focused row guaranteed to reuse the same cell instance that was previously stored as _focusedCell
?
Maybe @tomivirkki can provide some insight?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From some testing it seems that this is not the case:
Bildschirmaufnahme.2024-08-29.um.08.57.58.mov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did you do that? And did you get focus just with a click? With 2 finger scrolling, it works for me as expected and I lose focus as soon as I press the scrollbar's handle
|
Based on Sasha's finding, it appears that the current solution is not fully complete and will require some additional work, so I'll mark the PR as draft. |
Closing the PR based on @vursen 's comment. Keeping the branch for future reference when fixing the issue. |
Description
The part
focused-cell
isn't affected by the virtual scrolling of the grid. This PR makes the grid update thefocused-cell
whenever items are updated.When keyboard navigating, an outline was applied to the (DOM) cell even though the focused item was scrolled out of view. As the part name is removed when scrolling, the part name could not be used to target a style
outline: none
. So I addedoutline: none
to all cells (the focus ring is implemented with an inset box-shadow anyway).Fixes #7614
Type of change