@vaadin/popover 25.0.0-alpha15 → 25.0.0-alpha17
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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/popover",
|
|
3
|
-
"version": "25.0.0-
|
|
3
|
+
"version": "25.0.0-alpha17",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -36,23 +36,23 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
39
|
-
"@vaadin/a11y-base": "25.0.0-
|
|
40
|
-
"@vaadin/component-base": "25.0.0-
|
|
41
|
-
"@vaadin/lit-renderer": "25.0.0-
|
|
42
|
-
"@vaadin/overlay": "25.0.0-
|
|
43
|
-
"@vaadin/vaadin-themable-mixin": "25.0.0-
|
|
39
|
+
"@vaadin/a11y-base": "25.0.0-alpha17",
|
|
40
|
+
"@vaadin/component-base": "25.0.0-alpha17",
|
|
41
|
+
"@vaadin/lit-renderer": "25.0.0-alpha17",
|
|
42
|
+
"@vaadin/overlay": "25.0.0-alpha17",
|
|
43
|
+
"@vaadin/vaadin-themable-mixin": "25.0.0-alpha17",
|
|
44
44
|
"lit": "^3.0.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@vaadin/chai-plugins": "25.0.0-
|
|
48
|
-
"@vaadin/test-runner-commands": "25.0.0-
|
|
47
|
+
"@vaadin/chai-plugins": "25.0.0-alpha17",
|
|
48
|
+
"@vaadin/test-runner-commands": "25.0.0-alpha17",
|
|
49
49
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
50
|
-
"@vaadin/vaadin-lumo-styles": "25.0.0-
|
|
51
|
-
"sinon": "^
|
|
50
|
+
"@vaadin/vaadin-lumo-styles": "25.0.0-alpha17",
|
|
51
|
+
"sinon": "^21.0.0"
|
|
52
52
|
},
|
|
53
53
|
"web-types": [
|
|
54
54
|
"web-types.json",
|
|
55
55
|
"web-types.lit.json"
|
|
56
56
|
],
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "8264c71309907be99368b09414f0f8d7f591e0b9"
|
|
58
58
|
}
|
|
@@ -34,11 +34,17 @@ class PopoverOverlay extends PopoverOverlayMixin(
|
|
|
34
34
|
return popoverOverlayStyles;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
static get lumoInjector() {
|
|
38
|
+
return {
|
|
39
|
+
includeBaseStyles: true,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
37
43
|
/** @protected */
|
|
38
44
|
render() {
|
|
39
45
|
return html`
|
|
40
46
|
<div id="backdrop" part="backdrop" hidden ?hidden="${!this.withBackdrop}"></div>
|
|
41
|
-
<div part="overlay" id="overlay"
|
|
47
|
+
<div part="overlay" id="overlay">
|
|
42
48
|
<div part="arrow"></div>
|
|
43
49
|
<div part="content" id="content"><slot></slot></div>
|
|
44
50
|
</div>
|
|
@@ -69,10 +75,11 @@ class PopoverOverlay extends PopoverOverlayMixin(
|
|
|
69
75
|
}
|
|
70
76
|
|
|
71
77
|
/**
|
|
72
|
-
*
|
|
78
|
+
* Override method from OverlayFocusMixin to use owner as focus trap root
|
|
73
79
|
* @protected
|
|
80
|
+
* @override
|
|
74
81
|
*/
|
|
75
|
-
get
|
|
82
|
+
get _focusTrapRoot() {
|
|
76
83
|
return this.owner;
|
|
77
84
|
}
|
|
78
85
|
|
package/src/vaadin-popover.js
CHANGED
|
@@ -215,8 +215,21 @@ class Popover extends PopoverPositionMixin(
|
|
|
215
215
|
|
|
216
216
|
static get styles() {
|
|
217
217
|
return css`
|
|
218
|
-
:host
|
|
219
|
-
|
|
218
|
+
:host([opened]),
|
|
219
|
+
:host([opening]),
|
|
220
|
+
:host([closing]) {
|
|
221
|
+
display: block !important;
|
|
222
|
+
position: absolute;
|
|
223
|
+
outline: none;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
:host,
|
|
227
|
+
:host([hidden]) {
|
|
228
|
+
display: none !important;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
:host(:focus-visible) ::part(overlay) {
|
|
232
|
+
outline: var(--vaadin-focus-ring-width) solid var(--vaadin-focus-ring-color);
|
|
220
233
|
}
|
|
221
234
|
`;
|
|
222
235
|
}
|
|
@@ -422,7 +435,7 @@ class Popover extends PopoverPositionMixin(
|
|
|
422
435
|
}
|
|
423
436
|
|
|
424
437
|
static get observers() {
|
|
425
|
-
return ['
|
|
438
|
+
return ['__updateAriaAttributes(opened, role, target)'];
|
|
426
439
|
}
|
|
427
440
|
|
|
428
441
|
/**
|
|
@@ -531,6 +544,16 @@ class Popover extends PopoverPositionMixin(
|
|
|
531
544
|
|
|
532
545
|
this._overlayElement = this.$.overlay;
|
|
533
546
|
|
|
547
|
+
this.setAttribute('tabindex', '0');
|
|
548
|
+
|
|
549
|
+
this.addEventListener('focusin', (e) => {
|
|
550
|
+
this.__onFocusIn(e);
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
this.addEventListener('focusout', (e) => {
|
|
554
|
+
this.__onFocusOut(e);
|
|
555
|
+
});
|
|
556
|
+
|
|
534
557
|
if (!this.hasAttribute('role')) {
|
|
535
558
|
this.role = 'dialog';
|
|
536
559
|
}
|
|
@@ -549,6 +572,11 @@ class Popover extends PopoverPositionMixin(
|
|
|
549
572
|
updated(props) {
|
|
550
573
|
super.updated(props);
|
|
551
574
|
|
|
575
|
+
if (props.has('width') || props.has('height')) {
|
|
576
|
+
const { width, height } = this;
|
|
577
|
+
requestAnimationFrame(() => this.$.overlay.setBounds({ width, height }, false));
|
|
578
|
+
}
|
|
579
|
+
|
|
552
580
|
if (props.has('accessibleName')) {
|
|
553
581
|
if (this.accessibleName) {
|
|
554
582
|
this.setAttribute('aria-label', this.accessibleName);
|
|
@@ -564,6 +592,14 @@ class Popover extends PopoverPositionMixin(
|
|
|
564
592
|
this.removeAttribute('aria-labelledby');
|
|
565
593
|
}
|
|
566
594
|
}
|
|
595
|
+
|
|
596
|
+
if (props.has('modal')) {
|
|
597
|
+
if (this.modal) {
|
|
598
|
+
this.setAttribute('aria-modal', 'true');
|
|
599
|
+
} else {
|
|
600
|
+
this.removeAttribute('aria-modal');
|
|
601
|
+
}
|
|
602
|
+
}
|
|
567
603
|
}
|
|
568
604
|
|
|
569
605
|
/** @protected */
|
|
@@ -688,20 +724,18 @@ class Popover extends PopoverPositionMixin(
|
|
|
688
724
|
|
|
689
725
|
/** @private */
|
|
690
726
|
__onGlobalTab(event) {
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
// Move focus to the popover content on target element Tab
|
|
727
|
+
// Move focus to the popover on target element Tab
|
|
694
728
|
if (this.target && isElementFocused(this.__getTargetFocusable())) {
|
|
695
729
|
event.preventDefault();
|
|
696
|
-
|
|
730
|
+
this.focus();
|
|
697
731
|
return;
|
|
698
732
|
}
|
|
699
733
|
|
|
700
734
|
// Move focus to the next element after target on content Tab
|
|
701
|
-
const lastFocusable = this.__getLastFocusable(
|
|
735
|
+
const lastFocusable = this.__getLastFocusable(this);
|
|
702
736
|
if (lastFocusable && isElementFocused(lastFocusable)) {
|
|
703
737
|
const focusable = this.__getNextBodyFocusable(this.__getTargetFocusable());
|
|
704
|
-
if (focusable && focusable !==
|
|
738
|
+
if (focusable && focusable !== this) {
|
|
705
739
|
event.preventDefault();
|
|
706
740
|
focusable.focus();
|
|
707
741
|
return;
|
|
@@ -711,7 +745,7 @@ class Popover extends PopoverPositionMixin(
|
|
|
711
745
|
// Prevent focusing the popover content on previous element Tab
|
|
712
746
|
const activeElement = getDeepActiveElement();
|
|
713
747
|
const nextFocusable = this.__getNextBodyFocusable(activeElement);
|
|
714
|
-
if (nextFocusable ===
|
|
748
|
+
if (nextFocusable === this && lastFocusable) {
|
|
715
749
|
// Move focus to the last overlay focusable and do NOT prevent keydown
|
|
716
750
|
// to move focus outside the popover content (e.g. to the URL bar).
|
|
717
751
|
lastFocusable.focus();
|
|
@@ -720,16 +754,14 @@ class Popover extends PopoverPositionMixin(
|
|
|
720
754
|
|
|
721
755
|
/** @private */
|
|
722
756
|
__onGlobalShiftTab(event) {
|
|
723
|
-
const overlayPart = this._overlayElement.$.overlay;
|
|
724
|
-
|
|
725
757
|
// Prevent restoring focus after target blur on Shift + Tab
|
|
726
758
|
if (this.target && isElementFocused(this.__getTargetFocusable()) && this.__shouldRestoreFocus) {
|
|
727
759
|
this.__shouldRestoreFocus = false;
|
|
728
760
|
return;
|
|
729
761
|
}
|
|
730
762
|
|
|
731
|
-
// Move focus back to the target on
|
|
732
|
-
if (this.target && isElementFocused(
|
|
763
|
+
// Move focus back to the target on popover Shift + Tab
|
|
764
|
+
if (this.target && isElementFocused(this)) {
|
|
733
765
|
event.preventDefault();
|
|
734
766
|
this.__getTargetFocusable().focus();
|
|
735
767
|
return;
|
|
@@ -738,7 +770,7 @@ class Popover extends PopoverPositionMixin(
|
|
|
738
770
|
// Move focus back to the popover on next element Shift + Tab
|
|
739
771
|
const nextFocusable = this.__getNextBodyFocusable(this.__getTargetFocusable());
|
|
740
772
|
if (nextFocusable && isElementFocused(nextFocusable)) {
|
|
741
|
-
const lastFocusable = this.__getLastFocusable(
|
|
773
|
+
const lastFocusable = this.__getLastFocusable(this);
|
|
742
774
|
if (lastFocusable) {
|
|
743
775
|
event.preventDefault();
|
|
744
776
|
lastFocusable.focus();
|
|
@@ -834,7 +866,7 @@ class Popover extends PopoverPositionMixin(
|
|
|
834
866
|
}
|
|
835
867
|
|
|
836
868
|
/** @private */
|
|
837
|
-
|
|
869
|
+
__onFocusIn() {
|
|
838
870
|
this.__focusInside = true;
|
|
839
871
|
|
|
840
872
|
// When using Tab to move focus, restoring focus is reset. However, if pressing Tab
|
|
@@ -845,7 +877,7 @@ class Popover extends PopoverPositionMixin(
|
|
|
845
877
|
}
|
|
846
878
|
|
|
847
879
|
/** @private */
|
|
848
|
-
|
|
880
|
+
__onFocusOut(event) {
|
|
849
881
|
// Do not close the popover on overlay focusout if it's not the last one.
|
|
850
882
|
// This covers the following cases of nested overlay based components:
|
|
851
883
|
// 1. Moving focus to the nested overlay (e.g. vaadin-select, vaadin-menu-bar)
|
|
@@ -857,7 +889,6 @@ class Popover extends PopoverPositionMixin(
|
|
|
857
889
|
if (
|
|
858
890
|
(this.__hasTrigger('focus') && this.__mouseDownInside) ||
|
|
859
891
|
event.relatedTarget === this.target ||
|
|
860
|
-
event.relatedTarget === this._overlayElement ||
|
|
861
892
|
this.contains(event.relatedTarget)
|
|
862
893
|
) {
|
|
863
894
|
return;
|
|
@@ -946,7 +977,7 @@ class Popover extends PopoverPositionMixin(
|
|
|
946
977
|
/** @private */
|
|
947
978
|
__onOverlayOpened() {
|
|
948
979
|
if (this.autofocus && !this.modal) {
|
|
949
|
-
this.
|
|
980
|
+
this.focus();
|
|
950
981
|
}
|
|
951
982
|
}
|
|
952
983
|
|
|
@@ -993,13 +1024,6 @@ class Popover extends PopoverPositionMixin(
|
|
|
993
1024
|
return Array.isArray(this.trigger) && this.trigger.includes(trigger);
|
|
994
1025
|
}
|
|
995
1026
|
|
|
996
|
-
/** @private */
|
|
997
|
-
__sizeChanged(width, height, overlay) {
|
|
998
|
-
if (overlay) {
|
|
999
|
-
requestAnimationFrame(() => overlay.setBounds({ width, height }, false));
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
1027
|
/**
|
|
1004
1028
|
* Fired when the popover is closed.
|
|
1005
1029
|
*
|
package/web-types.json
CHANGED