Skip to content
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

Closed
wants to merge 6 commits into from

Conversation

FrediWa
Copy link
Contributor

@FrediWa FrediWa commented Aug 16, 2024

Description

The part focused-cell isn't affected by the virtual scrolling of the grid. This PR makes the grid update the focused-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 added outline: none to all cells (the focus ring is implemented with an inset box-shadow anyway).

Fixes #7614

Type of change

  • Bugfix

@FrediWa FrediWa changed the title fix: add/remove focused-cell when scrolling grid fix: add and remove focused-cell part when scrolling grid Aug 16, 2024
@FrediWa FrediWa marked this pull request as ready for review August 16, 2024 10:10
@FrediWa FrediWa requested a review from web-padawan August 16, 2024 10:10
@FrediWa FrediWa requested review from web-padawan and vursen and removed request for web-padawan and vursen August 27, 2024 10:34
@@ -855,6 +856,16 @@ export const GridMixin = (superClass) =>
this._getItem(index, row);
}

/** @private */
_updateFocusedItem(row) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_updateFocusedItem(row) {
__updateFocusedItem(row) {

We wanted to start using double underscores for private methods.

Copy link
Member

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;
Copy link
Contributor

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?

Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link

@vursen
Copy link
Contributor

vursen commented Sep 3, 2024

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.

@vursen vursen marked this pull request as draft September 3, 2024 07:41
@yuriy-fix
Copy link
Contributor

Closing the PR based on @vursen 's comment. Keeping the branch for future reference when fixing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Recurring focussed cell when scrolling in tables with many entries
5 participants