Skip to content

Commit 7eef011

Browse files
committed
fix: mark root element focused in interaction mode
1 parent 0f0b253 commit 7eef011

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

packages/virtual-list/src/vaadin-virtual-list-selection-mixin.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ export const SelectionMixin = (superClass) =>
112112
el.toggleAttribute('selected', this.__isSelected(item));
113113
const isFocusable = this.__isNavigating() && this.__focusIndex === index;
114114
el.tabIndex = isFocusable ? 0 : -1;
115-
el.toggleAttribute('focused', isFocusable && el.contains(this.__getActiveElement()));
115+
el.toggleAttribute(
116+
'focused',
117+
this.__isSelectable() && this.__focusIndex === index && el.contains(this.__getActiveElement()),
118+
);
116119

117120
el.role = this.__isSelectable() ? 'option' : 'listitem';
118121
el.ariaSelected = this.__isSelectable() ? String(this.__isSelected(item)) : null;

packages/virtual-list/test/virtual-list-selection.common.ts

+7
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,13 @@ describe('selection', () => {
521521
expect(list.hasAttribute('interacting')).to.be.true;
522522
});
523523

524+
it('should have the root element in focused state', async () => {
525+
beforeButton.focus();
526+
await sendKeys({ press: 'Tab' });
527+
await sendKeys({ press: 'Enter' });
528+
expect(getRenderedItem(0)!.hasAttribute('focused')).to.be.true;
529+
});
530+
524531
it('should focus tab to the next focusable child', async () => {
525532
beforeButton.focus();
526533
await sendKeys({ press: 'Tab' });

0 commit comments

Comments
 (0)