-
Notifications
You must be signed in to change notification settings - Fork 83
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: ensure no focus outline when item is scrolled out of view #7980
Conversation
d585d3a
to
e174d3e
Compare
if (isFocusedItemRendered) { | ||
// Ensure the correct element is focused, as the virtualizer | ||
// may use different elements when re-rendering visible items. | ||
this.__updateItemsFocusable(); |
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.
note: Debouncer + __updateItemsFocusable
fixes #7659 (comment). It also fixes cases where scrolling back to the focused item is triggered by Tab or an arrow key.
Here is a snippet that I used for testing: <style>
vaadin-grid::part(focused-cell)::before {
content: '';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
pointer-events: none;
box-shadow: inset 0 0 0 2px var(--lumo-primary-color-50pct);
}
</style>
<script type="module">
import '@vaadin/grid';
const grid = document.querySelector('vaadin-grid');
grid.items = Array.from({ length: 500 }, (_, i) => `Item-${i}`);
grid.querySelectorAll('vaadin-grid-column').forEach((column) => {
column.headerRenderer = (root, column, model) => {
root.textContent = 'Header';
}
column.renderer = (root, column, model) => {
root.textContent = model.item;
}
column.footerRenderer = (root, column, model) => {
root.textContent = 'Footer';
}
})
</script>
<vaadin-grid>
<vaadin-grid-column></vaadin-grid-column>
<vaadin-grid-column></vaadin-grid-column>
</vaadin-grid> Before: Screen.Recording.2024-10-17.at.10.38.31.movAfter: Screen.Recording.2024-10-17.at.10.39.06.mov |
[part~='cell'] { | ||
outline: none; | ||
} |
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.
this.toggleAttribute('navigating', true); | ||
/** @protected */ | ||
_preventScrollerRotatingCellFocus() { | ||
if (this._activeRowGroup !== this.$.items) { |
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.
note: This is an optimization to avoid triggering the debouncer when there is no focus within the items container.
|
Quality Gate passedIssues Measures |
#7998) Co-authored-by: Sergey Vinogradov <[email protected]>
#7999) Co-authored-by: Sergey Vinogradov <[email protected]>
Description
Fixes the issue where the focus outline repeatedly appeared on random items as the user scrolled when the actual focused item was out of view. This specifically happened if the item was focused by the mouse and a custom CSS was applied to show the focus outline on clicks:
Depends on
Fixes #7614
Type of change