Skip to content

Commit 3d4680b

Browse files
fix: restore select focus on fullscreen dropdown close (#3120) (#3121)
Co-authored-by: Tomi Virkki <tomivirkki@users.noreply.github.com>
1 parent 3f635b3 commit 3d4680b

3 files changed

Lines changed: 8 additions & 12 deletions

File tree

‎dev/select.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</script>
1111
</head>
1212
<body>
13-
<vaadin-select></vaadin-select>
13+
<vaadin-select label="Size"></vaadin-select>
1414

1515
<script>
1616
const select = document.querySelector('vaadin-select');

‎packages/select/src/vaadin-select.js‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -489,13 +489,9 @@ class Select extends DelegateFocusMixin(FieldMixin(SlotMixin(ElementMixin(Themab
489489

490490
this._menuElement.focus();
491491
} else if (wasOpened) {
492-
if (this._phone) {
493-
this._setFocused(false);
494-
} else {
495-
this.focus();
496-
if (this._openedWithFocusRing) {
497-
this.setAttribute('focus-ring', '');
498-
}
492+
this.focus();
493+
if (this._openedWithFocusRing) {
494+
this.setAttribute('focus-ring', '');
499495
}
500496
this.validate();
501497
}

‎packages/select/test/select.test.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,19 +375,19 @@ describe('vaadin-select', () => {
375375
expect(focusedSpy.called).to.be.true;
376376
});
377377

378-
it('should remove focused state on closing the overlay if phone', () => {
378+
it('should restore focused state on closing the overlay if phone', () => {
379379
select._phone = true;
380380
click(select._items[1]);
381-
expect(select.hasAttribute('focused')).to.be.false;
381+
expect(select.hasAttribute('focused')).to.be.true;
382382
});
383383

384-
it('should not focus the button on closing the overlay if phone', () => {
384+
it('should focus the button on closing the overlay if phone', () => {
385385
const focusedSpy = sinon.spy();
386386
select.focusElement.focus = focusedSpy;
387387

388388
select._phone = true;
389389
click(select._items[1]);
390-
expect(focusedSpy.called).to.be.false;
390+
expect(focusedSpy.called).to.be.true;
391391
});
392392

393393
it('should focus the button before moving the focus to next selectable element', () => {

0 commit comments

Comments
 (0)