-
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
Changes from 5 commits
4b1be2f
cbf2ff8
9511459
262f131
b29d9fe
835e6c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ import { DragAndDropMixin } from './vaadin-grid-drag-and-drop-mixin.js'; | |
import { DynamicColumnsMixin } from './vaadin-grid-dynamic-columns-mixin.js'; | ||
import { EventContextMixin } from './vaadin-grid-event-context-mixin.js'; | ||
import { FilterMixin } from './vaadin-grid-filter-mixin.js'; | ||
import { updatePart } from './vaadin-grid-helpers.js'; | ||
import { | ||
getBodyRowCells, | ||
iterateChildren, | ||
|
@@ -855,6 +856,16 @@ export const GridMixin = (superClass) => | |
this._getItem(index, row); | ||
} | ||
|
||
/** @private */ | ||
_updateFocusedItem(row) { | ||
const focusedItemInRow = row.__virtualIndex === this._focusedItemIndex; | ||
tomivirkki marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let isFocusedCell; | ||
tomivirkki marked this conversation as resolved.
Show resolved
Hide resolved
|
||
iterateChildren(row, (cell) => { | ||
isFocusedCell = cell === this._focusedCell; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Maybe @tomivirkki can provide some insight? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.movThere was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
updatePart(cell, isFocusedCell && focusedItemInRow, 'focused-cell'); | ||
}); | ||
} | ||
|
||
/** @private */ | ||
_columnTreeChanged(columnTree) { | ||
this._renderColumnTree(columnTree); | ||
|
@@ -957,6 +968,7 @@ export const GridMixin = (superClass) => | |
_updateItem(row, item) { | ||
row._item = item; | ||
const model = this.__getRowModel(row); | ||
this._updateFocusedItem(row); | ||
|
||
this._toggleDetailsCell(row, model.detailsOpened); | ||
|
||
|
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.
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.
https://polymer-library.polymer-project.org/3.0/docs/devguide/properties#private-and-protected-properties