Skip to content

Commit 2b2e367

Browse files
authored
fix: do not close overlay with iOS VoiceOver (#4279)
1 parent 0ce4dec commit 2b2e367

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

‎packages/combo-box/src/vaadin-combo-box-mixin.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,12 @@ export const ComboBoxMixin = (subclass) =>
12521252

12531253
/** @private */
12541254
_onFocusout(event) {
1255+
// VoiceOver on iOS fires `focusout` event when moving focus to the item in the dropdown.
1256+
// Do not focus the input in this case, because it would break announcement for the item.
1257+
if (event.relatedTarget && event.relatedTarget.localName === `${this._tagNamePrefix}-item`) {
1258+
return;
1259+
}
1260+
12551261
// Fixes the problem with `focusout` happening when clicking on the scroll bar on Edge
12561262
if (event.relatedTarget === this.$.overlay) {
12571263
event.composedPath()[0].focus();

‎packages/combo-box/test/toggling-dropdown.test.js‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import sinon from 'sinon';
55
import '@vaadin/polymer-legacy-adapter/template-renderer.js';
66
import './not-animated-styles.js';
77
import '../vaadin-combo-box.js';
8-
import { outsideClick, setInputValue } from './helpers.js';
8+
import { getFirstItem, outsideClick, setInputValue } from './helpers.js';
99

1010
describe('toggling dropdown', () => {
1111
let comboBox, overlay, input;
@@ -241,6 +241,15 @@ describe('toggling dropdown', () => {
241241
expect(comboBox.opened).to.be.false;
242242
});
243243

244+
it('should not close the overlay when focus is moved to item', () => {
245+
comboBox.open();
246+
247+
const item = getFirstItem(comboBox);
248+
focusout(input, item);
249+
250+
expect(comboBox.opened).to.be.true;
251+
});
252+
244253
it('should restore focus to the field on outside click', async () => {
245254
comboBox.focus();
246255
comboBox.open();

0 commit comments

Comments
 (0)