@vaadin/combo-box 25.0.0-alpha3 → 25.0.0-alpha5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,786 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2015 - 2025 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { DisabledMixin } from '@vaadin/a11y-base/src/disabled-mixin.js';
7
+ import { FocusMixin } from '@vaadin/a11y-base/src/focus-mixin.js';
8
+ import { isElementFocused, isKeyboardActive } from '@vaadin/a11y-base/src/focus-utils.js';
9
+ import { KeyboardMixin } from '@vaadin/a11y-base/src/keyboard-mixin.js';
10
+ import { isTouch } from '@vaadin/component-base/src/browser-utils.js';
11
+ import { OverlayClassMixin } from '@vaadin/component-base/src/overlay-class-mixin.js';
12
+ import { InputMixin } from '@vaadin/field-base/src/input-mixin.js';
13
+ import { VirtualKeyboardController } from '@vaadin/field-base/src/virtual-keyboard-controller.js';
14
+ import { ComboBoxPlaceholder } from './vaadin-combo-box-placeholder.js';
15
+
16
+ /**
17
+ * @polymerMixin
18
+ * @mixes DisabledMixin
19
+ * @mixes FocusMixin
20
+ * @mixes InputMixin
21
+ * @mixes KeyboardMixin
22
+ * @mixes OverlayClassMixin
23
+ * @param {function(new:HTMLElement)} superClass
24
+ */
25
+ export const ComboBoxBaseMixin = (superClass) =>
26
+ class ComboBoxMixinBaseClass extends OverlayClassMixin(
27
+ KeyboardMixin(InputMixin(DisabledMixin(FocusMixin(superClass)))),
28
+ ) {
29
+ static get properties() {
30
+ return {
31
+ /**
32
+ * True if the dropdown is open, false otherwise.
33
+ * @type {boolean}
34
+ */
35
+ opened: {
36
+ type: Boolean,
37
+ notify: true,
38
+ value: false,
39
+ reflectToAttribute: true,
40
+ sync: true,
41
+ observer: '_openedChanged',
42
+ },
43
+
44
+ /**
45
+ * Set true to prevent the overlay from opening automatically.
46
+ * @attr {boolean} auto-open-disabled
47
+ */
48
+ autoOpenDisabled: {
49
+ type: Boolean,
50
+ sync: true,
51
+ },
52
+
53
+ /**
54
+ * When present, it specifies that the field is read-only.
55
+ * @type {boolean}
56
+ */
57
+ readonly: {
58
+ type: Boolean,
59
+ value: false,
60
+ reflectToAttribute: true,
61
+ },
62
+
63
+ /**
64
+ * @type {number}
65
+ * @protected
66
+ */
67
+ _focusedIndex: {
68
+ type: Number,
69
+ observer: '_focusedIndexChanged',
70
+ value: -1,
71
+ sync: true,
72
+ },
73
+
74
+ /**
75
+ * @type {!HTMLElement | undefined}
76
+ * @protected
77
+ */
78
+ _toggleElement: {
79
+ type: Object,
80
+ observer: '_toggleElementChanged',
81
+ },
82
+
83
+ /**
84
+ * Set of items to be rendered in the dropdown.
85
+ * @protected
86
+ */
87
+ _dropdownItems: {
88
+ type: Array,
89
+ sync: true,
90
+ },
91
+
92
+ /**
93
+ * Whether the overlay should be opened.
94
+ * @protected
95
+ */
96
+ _overlayOpened: {
97
+ type: Boolean,
98
+ sync: true,
99
+ observer: '_overlayOpenedChanged',
100
+ },
101
+ };
102
+ }
103
+
104
+ constructor() {
105
+ super();
106
+
107
+ /**
108
+ * Reference to the `vaadin-combo-box-scroller` element instance.
109
+ * Do not define in `properties` to avoid triggering updates.
110
+ * @type {HTMLElement}
111
+ * @protected
112
+ */
113
+ this._scroller;
114
+
115
+ /**
116
+ * Used to detect if focusout should be ignored due to touch.
117
+ * Do not define in `properties` to avoid triggering updates.
118
+ * @type {boolean}
119
+ * @protected
120
+ */
121
+ this._closeOnBlurIsPrevented;
122
+
123
+ this._boundOverlaySelectedItemChanged = this._overlaySelectedItemChanged.bind(this);
124
+ this._boundOnClearButtonMouseDown = this.__onClearButtonMouseDown.bind(this);
125
+ this._boundOnClick = this._onClick.bind(this);
126
+ this._boundOnOverlayTouchAction = this._onOverlayTouchAction.bind(this);
127
+ this._boundOnTouchend = this._onTouchend.bind(this);
128
+ }
129
+
130
+ /**
131
+ * Tag name prefix used by scroller and items.
132
+ * @protected
133
+ * @return {string}
134
+ */
135
+ get _tagNamePrefix() {
136
+ return 'vaadin-combo-box';
137
+ }
138
+
139
+ /**
140
+ * Override method inherited from `InputMixin`
141
+ * to customize the input element.
142
+ * @protected
143
+ * @override
144
+ */
145
+ _inputElementChanged(input) {
146
+ super._inputElementChanged(input);
147
+
148
+ if (input) {
149
+ input.autocomplete = 'off';
150
+ input.autocapitalize = 'off';
151
+
152
+ input.setAttribute('role', 'combobox');
153
+ input.setAttribute('aria-autocomplete', 'list');
154
+ input.setAttribute('aria-expanded', !!this.opened);
155
+
156
+ // Disable the macOS Safari spell check auto corrections.
157
+ input.setAttribute('spellcheck', 'false');
158
+
159
+ // Disable iOS autocorrect suggestions.
160
+ input.setAttribute('autocorrect', 'off');
161
+ }
162
+ }
163
+
164
+ /** @protected */
165
+ firstUpdated() {
166
+ super.firstUpdated();
167
+
168
+ // Init scroller in `firstUpdated()` to ensure the `_scroller` reference
169
+ // is available by the time property observer runs. Also, do not store it
170
+ // in a reactive property to avoid triggering another unnecessary update.
171
+ this._initScroller();
172
+ }
173
+
174
+ /** @protected */
175
+ ready() {
176
+ super.ready();
177
+
178
+ this._initOverlay();
179
+
180
+ this.addEventListener('click', this._boundOnClick);
181
+ this.addEventListener('touchend', this._boundOnTouchend);
182
+
183
+ if (this.clearElement) {
184
+ this.clearElement.addEventListener('mousedown', this._boundOnClearButtonMouseDown);
185
+ }
186
+
187
+ const bringToFrontListener = () => {
188
+ requestAnimationFrame(() => {
189
+ this._overlayElement.bringToFront();
190
+ });
191
+ };
192
+
193
+ this.addEventListener('mousedown', bringToFrontListener);
194
+ this.addEventListener('touchstart', bringToFrontListener);
195
+
196
+ this.addController(new VirtualKeyboardController(this));
197
+ }
198
+
199
+ /** @protected */
200
+ disconnectedCallback() {
201
+ super.disconnectedCallback();
202
+
203
+ // Close the overlay on detach
204
+ this.close();
205
+ }
206
+
207
+ /**
208
+ * Opens the dropdown list.
209
+ */
210
+ open() {
211
+ // Prevent _open() being called when input is disabled or read-only
212
+ if (!this.disabled && !this.readonly) {
213
+ this.opened = true;
214
+ }
215
+ }
216
+
217
+ /**
218
+ * Closes the dropdown list.
219
+ */
220
+ close() {
221
+ this.opened = false;
222
+ }
223
+
224
+ /** @private */
225
+ _initOverlay() {
226
+ const overlay = this.$.overlay;
227
+
228
+ // Store instance for detecting "dir" attribute on opening
229
+ overlay._comboBox = this;
230
+
231
+ overlay.addEventListener('touchend', this._boundOnOverlayTouchAction);
232
+ overlay.addEventListener('touchmove', this._boundOnOverlayTouchAction);
233
+
234
+ // Prevent blurring the input when clicking inside the overlay
235
+ overlay.addEventListener('mousedown', (e) => e.preventDefault());
236
+
237
+ // Manual two-way binding for the overlay "opened" property
238
+ overlay.addEventListener('opened-changed', (e) => {
239
+ this._overlayOpened = e.detail.value;
240
+ });
241
+
242
+ this._overlayElement = overlay;
243
+ }
244
+
245
+ /**
246
+ * Create and initialize the scroller element.
247
+ * Override to provide custom host reference.
248
+ *
249
+ * @protected
250
+ */
251
+ _initScroller(host) {
252
+ const scroller = document.createElement(`${this._tagNamePrefix}-scroller`);
253
+
254
+ scroller.owner = host || this;
255
+ scroller.getItemLabel = this._getItemLabel.bind(this);
256
+ scroller.addEventListener('selection-changed', this._boundOverlaySelectedItemChanged);
257
+
258
+ const overlay = this.$.overlay;
259
+
260
+ overlay.renderer = (root) => {
261
+ if (!root.innerHTML) {
262
+ root.appendChild(scroller);
263
+ }
264
+ };
265
+
266
+ // Ensure the scroller is rendered
267
+ overlay.requestContentUpdate();
268
+
269
+ this._scroller = scroller;
270
+ }
271
+
272
+ /**
273
+ * @type {boolean}
274
+ * @protected
275
+ */
276
+ get _hasDropdownItems() {
277
+ return !!(this._dropdownItems && this._dropdownItems.length);
278
+ }
279
+
280
+ /** @private */
281
+ _overlayOpenedChanged(opened, wasOpened) {
282
+ if (opened) {
283
+ this._onOpened();
284
+ } else if (wasOpened && this._hasDropdownItems) {
285
+ this.close();
286
+ this._onOverlayClosed();
287
+ }
288
+ }
289
+
290
+ /** @private */
291
+ _focusedIndexChanged(index, oldIndex) {
292
+ if (oldIndex === undefined) {
293
+ return;
294
+ }
295
+ this._updateActiveDescendant(index);
296
+ }
297
+
298
+ /** @protected */
299
+ _isInputFocused() {
300
+ return this.inputElement && isElementFocused(this.inputElement);
301
+ }
302
+
303
+ /** @private */
304
+ _updateActiveDescendant(index) {
305
+ const input = this.inputElement;
306
+ if (!input) {
307
+ return;
308
+ }
309
+
310
+ const item = this._getItemElements().find((el) => el.index === index);
311
+ if (item) {
312
+ input.setAttribute('aria-activedescendant', item.id);
313
+ } else {
314
+ input.removeAttribute('aria-activedescendant');
315
+ }
316
+ }
317
+
318
+ /** @private */
319
+ _openedChanged(opened, wasOpened) {
320
+ // Prevent _close() being called when opened is set to its default value (false).
321
+ if (wasOpened === undefined) {
322
+ return;
323
+ }
324
+
325
+ if (opened) {
326
+ // For touch devices, we don't want to popup virtual keyboard
327
+ // unless input element is explicitly focused by the user.
328
+ if (!this._isInputFocused() && !isTouch) {
329
+ if (this.inputElement) {
330
+ this.inputElement.focus();
331
+ }
332
+ }
333
+ } else {
334
+ this._onClosed();
335
+ }
336
+
337
+ const input = this.inputElement;
338
+ if (input) {
339
+ input.setAttribute('aria-expanded', !!opened);
340
+
341
+ if (opened) {
342
+ input.setAttribute('aria-controls', this._scroller.id);
343
+ } else {
344
+ input.removeAttribute('aria-controls');
345
+ }
346
+ }
347
+ }
348
+
349
+ /** @private */
350
+ _onOverlayTouchAction() {
351
+ // On touch devices, blur the input on touch start inside the overlay, in order to hide
352
+ // the virtual keyboard. But don't close the overlay on this blur.
353
+ this._closeOnBlurIsPrevented = true;
354
+ this.inputElement.blur();
355
+ this._closeOnBlurIsPrevented = false;
356
+ }
357
+
358
+ /** @protected */
359
+ _isClearButton(event) {
360
+ return event.composedPath()[0] === this.clearElement;
361
+ }
362
+
363
+ /** @private */
364
+ __onClearButtonMouseDown(event) {
365
+ event.preventDefault(); // Prevent native focusout event
366
+ this.inputElement.focus();
367
+ }
368
+
369
+ /**
370
+ * @param {Event} event
371
+ * @protected
372
+ */
373
+ _onClearButtonClick(event) {
374
+ event.preventDefault();
375
+ this._onClearAction();
376
+ }
377
+
378
+ /**
379
+ * @param {Event} event
380
+ * @private
381
+ */
382
+ _onToggleButtonClick(event) {
383
+ // Prevent parent components such as `vaadin-grid`
384
+ // from handling the click event after it bubbles.
385
+ event.preventDefault();
386
+
387
+ if (this.opened) {
388
+ this.close();
389
+ } else {
390
+ this.open();
391
+ }
392
+ }
393
+
394
+ /**
395
+ * @param {Event} event
396
+ * @protected
397
+ */
398
+ _onHostClick(event) {
399
+ if (!this.autoOpenDisabled) {
400
+ event.preventDefault();
401
+ this.open();
402
+ }
403
+ }
404
+
405
+ /** @private */
406
+ _onClick(event) {
407
+ if (this._isClearButton(event)) {
408
+ this._onClearButtonClick(event);
409
+ } else if (event.composedPath().includes(this._toggleElement)) {
410
+ this._onToggleButtonClick(event);
411
+ } else {
412
+ this._onHostClick(event);
413
+ }
414
+ }
415
+
416
+ /** @private */
417
+ _onTouchend(event) {
418
+ if (!this.clearElement || event.composedPath()[0] !== this.clearElement) {
419
+ return;
420
+ }
421
+
422
+ event.preventDefault();
423
+ this._onClearAction();
424
+ }
425
+
426
+ /**
427
+ * Override an event listener from `KeyboardMixin`.
428
+ *
429
+ * @param {KeyboardEvent} e
430
+ * @protected
431
+ * @override
432
+ */
433
+ _onKeyDown(e) {
434
+ super._onKeyDown(e);
435
+
436
+ if (e.key === 'ArrowDown') {
437
+ this._onArrowDown();
438
+
439
+ // Prevent caret from moving
440
+ e.preventDefault();
441
+ } else if (e.key === 'ArrowUp') {
442
+ this._onArrowUp();
443
+
444
+ // Prevent caret from moving
445
+ e.preventDefault();
446
+ }
447
+ }
448
+
449
+ /**
450
+ * Override to provide logic for item label path.
451
+ * @protected
452
+ */
453
+ _getItemLabel(item) {
454
+ return item ? item.toString() : '';
455
+ }
456
+
457
+ /** @private */
458
+ _onArrowDown() {
459
+ if (this.opened) {
460
+ const items = this._dropdownItems;
461
+ if (items) {
462
+ this._focusedIndex = Math.min(items.length - 1, this._focusedIndex + 1);
463
+ this._prefillFocusedItemLabel();
464
+ }
465
+ } else {
466
+ this.open();
467
+ }
468
+ }
469
+
470
+ /** @private */
471
+ _onArrowUp() {
472
+ if (this.opened) {
473
+ if (this._focusedIndex > -1) {
474
+ this._focusedIndex = Math.max(0, this._focusedIndex - 1);
475
+ } else {
476
+ const items = this._dropdownItems;
477
+ if (items) {
478
+ this._focusedIndex = items.length - 1;
479
+ }
480
+ }
481
+
482
+ this._prefillFocusedItemLabel();
483
+ } else {
484
+ this.open();
485
+ }
486
+ }
487
+
488
+ /** @private */
489
+ _prefillFocusedItemLabel() {
490
+ if (this._focusedIndex > -1) {
491
+ const focusedItem = this._dropdownItems[this._focusedIndex];
492
+ this._inputElementValue = this._getItemLabel(focusedItem);
493
+ this._markAllSelectionRange();
494
+ }
495
+ }
496
+
497
+ /** @private */
498
+ _setSelectionRange(start, end) {
499
+ // Setting selection range focuses and/or moves the caret in some browsers,
500
+ // and there's no need to modify the selection range if the input isn't focused anyway.
501
+ // This affects Safari. When the overlay is open, and then hitting tab, browser should focus
502
+ // the next focusable element instead of the combo-box itself.
503
+ if (this._isInputFocused() && this.inputElement.setSelectionRange) {
504
+ this.inputElement.setSelectionRange(start, end);
505
+ }
506
+ }
507
+
508
+ /** @private */
509
+ _markAllSelectionRange() {
510
+ if (this._inputElementValue !== undefined) {
511
+ this._setSelectionRange(0, this._inputElementValue.length);
512
+ }
513
+ }
514
+
515
+ /** @private */
516
+ _clearSelectionRange() {
517
+ if (this._inputElementValue !== undefined) {
518
+ const pos = this._inputElementValue ? this._inputElementValue.length : 0;
519
+ this._setSelectionRange(pos, pos);
520
+ }
521
+ }
522
+
523
+ /**
524
+ * @protected
525
+ */
526
+ _closeOrCommit() {
527
+ if (!this.opened) {
528
+ this._commitValue();
529
+ } else {
530
+ this.close();
531
+ }
532
+ }
533
+
534
+ /**
535
+ * Override an event listener from `KeyboardMixin`.
536
+ *
537
+ * @param {KeyboardEvent} e
538
+ * @protected
539
+ * @override
540
+ */
541
+ _onEnter(e) {
542
+ // Do not commit value when custom values are disallowed and input value is not a valid option
543
+ // also stop propagation of the event, otherwise the user could submit a form while the input
544
+ // still contains an invalid value
545
+ if (!this._hasValidInputValue()) {
546
+ // Do not submit the surrounding form.
547
+ e.preventDefault();
548
+ // Do not trigger global listeners
549
+ e.stopPropagation();
550
+ return;
551
+ }
552
+
553
+ // Stop propagation of the enter event only if the dropdown is opened, this
554
+ // "consumes" the enter event for the action of closing the dropdown
555
+ if (this.opened) {
556
+ // Do not submit the surrounding form.
557
+ e.preventDefault();
558
+ // Do not trigger global listeners
559
+ e.stopPropagation();
560
+ }
561
+
562
+ this._closeOrCommit();
563
+ }
564
+
565
+ /**
566
+ * Override this method to detect whether valid value is provided.
567
+ * @protected
568
+ */
569
+ _hasValidInputValue() {
570
+ return true;
571
+ }
572
+
573
+ /**
574
+ * Override an event listener from `KeyboardMixin`.
575
+ * Do not call `super` in order to override clear
576
+ * button logic defined in `InputControlMixin`.
577
+ *
578
+ * @param {!KeyboardEvent} e
579
+ * @protected
580
+ * @override
581
+ */
582
+ _onEscape(e) {
583
+ if (
584
+ this.autoOpenDisabled &&
585
+ (this.opened || (this.value !== this._inputElementValue && this._inputElementValue.length > 0))
586
+ ) {
587
+ // Auto-open is disabled
588
+ // The overlay is open or
589
+ // The input value has changed but the change hasn't been committed, so cancel it.
590
+ e.stopPropagation();
591
+ this._focusedIndex = -1;
592
+ this._onEscapeCancel();
593
+ } else if (this.opened) {
594
+ // Auto-open is enabled
595
+ // The overlay is open
596
+ e.stopPropagation();
597
+
598
+ if (this._focusedIndex > -1) {
599
+ // An item is focused, revert the input to the filtered value
600
+ this._focusedIndex = -1;
601
+ this._revertInputValue();
602
+ } else {
603
+ // No item is focused, cancel the change and close the overlay
604
+ this._onEscapeCancel();
605
+ }
606
+ } else if (this.clearButtonVisible && !!this.value && !this.readonly) {
607
+ e.stopPropagation();
608
+ // The clear button is visible and the overlay is closed, so clear the value.
609
+ this._onClearAction();
610
+ }
611
+ }
612
+
613
+ /**
614
+ * Override to handle canceling and closing overlay on Escape.
615
+ * @protected
616
+ */
617
+ _onEscapeCancel() {
618
+ // To be implemented
619
+ }
620
+
621
+ /** @private */
622
+ _toggleElementChanged(toggleElement) {
623
+ if (toggleElement) {
624
+ // Don't blur the input on toggle mousedown
625
+ toggleElement.addEventListener('mousedown', (e) => e.preventDefault());
626
+ // Unfocus previously focused element if focus is not inside combo box (on touch devices)
627
+ toggleElement.addEventListener('click', () => {
628
+ if (isTouch && !this._isInputFocused()) {
629
+ document.activeElement.blur();
630
+ }
631
+ });
632
+ }
633
+ }
634
+
635
+ /**
636
+ * Override to implement logic for clearing value.
637
+ * @protected
638
+ */
639
+ _onClearAction() {
640
+ // To be implemented
641
+ }
642
+
643
+ /**
644
+ * Override to implement logic for overlay opening.
645
+ * @protected
646
+ */
647
+ _onOpened() {
648
+ // To be implemented
649
+ }
650
+
651
+ /**
652
+ * Override to implement logic for changing opened to false.
653
+ * @protected
654
+ */
655
+ _onClosed() {
656
+ // To be implemented
657
+ }
658
+
659
+ /**
660
+ * Override to implement logic for overlay closing.
661
+ * @protected
662
+ */
663
+ _onOverlayClosed() {
664
+ // To be implemented
665
+ }
666
+
667
+ /**
668
+ * Override to implement logic for committing value.
669
+ * @protected
670
+ */
671
+ _commitValue() {
672
+ // To be implemented
673
+ }
674
+
675
+ /**
676
+ * Override to implement logic for value reverting.
677
+ * @protected
678
+ */
679
+ _revertInputValue() {
680
+ this._inputElementValue = this.value;
681
+ this._clearSelectionRange();
682
+ }
683
+
684
+ /**
685
+ * Override an event listener from `InputMixin`.
686
+ * @param {!Event} event
687
+ * @protected
688
+ * @override
689
+ */
690
+ _onInput(event) {
691
+ if (!this.opened && !this._isClearButton(event) && !this.autoOpenDisabled) {
692
+ this.opened = true;
693
+ }
694
+ }
695
+
696
+ /** @private */
697
+ _getItemElements() {
698
+ return Array.from(this._scroller.querySelectorAll(`${this._tagNamePrefix}-item`));
699
+ }
700
+
701
+ /** @protected */
702
+ _scrollIntoView(index) {
703
+ if (!this._scroller) {
704
+ return;
705
+ }
706
+ this._scroller.scrollIntoView(index);
707
+ }
708
+
709
+ /** @private */
710
+ _overlaySelectedItemChanged(e) {
711
+ // Stop this private event from leaking outside.
712
+ e.stopPropagation();
713
+
714
+ if (e.detail.item instanceof ComboBoxPlaceholder) {
715
+ // Placeholder items should not be selectable.
716
+ return;
717
+ }
718
+
719
+ if (this.opened) {
720
+ this._focusedIndex = this._dropdownItems.indexOf(e.detail.item);
721
+ this.close();
722
+ }
723
+ }
724
+
725
+ /**
726
+ * Override method inherited from `FocusMixin`
727
+ * to close the overlay on blur and commit the value.
728
+ *
729
+ * @param {boolean} focused
730
+ * @protected
731
+ * @override
732
+ */
733
+ _setFocused(focused) {
734
+ super._setFocused(focused);
735
+
736
+ if (!focused && !this.readonly && !this._closeOnBlurIsPrevented) {
737
+ this._handleFocusOut();
738
+ }
739
+ }
740
+
741
+ /**
742
+ * Override this method to provide custom logic for focusout.
743
+ * @protected
744
+ */
745
+ _handleFocusOut() {
746
+ if (isKeyboardActive()) {
747
+ // Close on Tab key causing blur. With mouse, close on outside click instead.
748
+ this._closeOrCommit();
749
+ return;
750
+ }
751
+
752
+ if (!this.opened) {
753
+ this._commitValue();
754
+ } else if (!this._overlayOpened) {
755
+ // Combo-box is opened, but overlay is not visible -> custom value was entered.
756
+ // Make sure we close here as there won't be an "outside click" in this case.
757
+ this.close();
758
+ }
759
+ }
760
+
761
+ /**
762
+ * Override method inherited from `FocusMixin` to not remove focused
763
+ * state when focus moves to the overlay.
764
+ *
765
+ * @param {FocusEvent} event
766
+ * @return {boolean}
767
+ * @protected
768
+ * @override
769
+ */
770
+ _shouldRemoveFocus(event) {
771
+ // VoiceOver on iOS fires `focusout` event when moving focus to the item in the dropdown.
772
+ // Do not focus the input in this case, because it would break announcement for the item.
773
+ if (event.relatedTarget && event.relatedTarget.localName === `${this._tagNamePrefix}-item`) {
774
+ return false;
775
+ }
776
+
777
+ // Do not blur when focus moves to the overlay
778
+ // Also, fixes the problem with `focusout` happening when clicking on the scroll bar on Edge
779
+ if (event.relatedTarget === this._overlayElement) {
780
+ event.composedPath()[0].focus();
781
+ return false;
782
+ }
783
+
784
+ return true;
785
+ }
786
+ };