@vaadin/popover 25.0.0-alpha15 → 25.0.0-alpha16

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-alpha15",
3
+ "version": "25.0.0-alpha16",
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-alpha15",
40
- "@vaadin/component-base": "25.0.0-alpha15",
41
- "@vaadin/lit-renderer": "25.0.0-alpha15",
42
- "@vaadin/overlay": "25.0.0-alpha15",
43
- "@vaadin/vaadin-themable-mixin": "25.0.0-alpha15",
39
+ "@vaadin/a11y-base": "25.0.0-alpha16",
40
+ "@vaadin/component-base": "25.0.0-alpha16",
41
+ "@vaadin/lit-renderer": "25.0.0-alpha16",
42
+ "@vaadin/overlay": "25.0.0-alpha16",
43
+ "@vaadin/vaadin-themable-mixin": "25.0.0-alpha16",
44
44
  "lit": "^3.0.0"
45
45
  },
46
46
  "devDependencies": {
47
- "@vaadin/chai-plugins": "25.0.0-alpha15",
48
- "@vaadin/test-runner-commands": "25.0.0-alpha15",
47
+ "@vaadin/chai-plugins": "25.0.0-alpha16",
48
+ "@vaadin/test-runner-commands": "25.0.0-alpha16",
49
49
  "@vaadin/testing-helpers": "^2.0.0",
50
- "@vaadin/vaadin-lumo-styles": "25.0.0-alpha15",
50
+ "@vaadin/vaadin-lumo-styles": "25.0.0-alpha16",
51
51
  "sinon": "^18.0.0"
52
52
  },
53
53
  "web-types": [
54
54
  "web-types.json",
55
55
  "web-types.lit.json"
56
56
  ],
57
- "gitHead": "1ad98437e7600769bf66f870929feefbeef16edf"
57
+ "gitHead": "4b316158a4a4f702f032bc9940fc82f0faa840f4"
58
58
  }
@@ -38,7 +38,7 @@ class PopoverOverlay extends PopoverOverlayMixin(
38
38
  render() {
39
39
  return html`
40
40
  <div id="backdrop" part="backdrop" hidden ?hidden="${!this.withBackdrop}"></div>
41
- <div part="overlay" id="overlay" tabindex="0">
41
+ <div part="overlay" id="overlay">
42
42
  <div part="arrow"></div>
43
43
  <div part="content" id="content"><slot></slot></div>
44
44
  </div>
@@ -69,10 +69,11 @@ class PopoverOverlay extends PopoverOverlayMixin(
69
69
  }
70
70
 
71
71
  /**
72
- * @override
72
+ * Override method from OverlayFocusMixin to use owner as focus trap root
73
73
  * @protected
74
+ * @override
74
75
  */
75
- get _modalRoot() {
76
+ get _focusTrapRoot() {
76
77
  return this.owner;
77
78
  }
78
79
 
@@ -215,8 +215,21 @@ class Popover extends PopoverPositionMixin(
215
215
 
216
216
  static get styles() {
217
217
  return css`
218
- :host {
219
- display: contents;
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) ::part(overlay) {
232
+ outline: var(--vaadin-focus-ring-width) solid var(--vaadin-focus-ring-color);
220
233
  }
221
234
  `;
222
235
  }
@@ -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
  }
@@ -564,6 +587,14 @@ class Popover extends PopoverPositionMixin(
564
587
  this.removeAttribute('aria-labelledby');
565
588
  }
566
589
  }
590
+
591
+ if (props.has('modal')) {
592
+ if (this.modal) {
593
+ this.setAttribute('aria-modal', 'true');
594
+ } else {
595
+ this.removeAttribute('aria-modal');
596
+ }
597
+ }
567
598
  }
568
599
 
569
600
  /** @protected */
@@ -688,20 +719,18 @@ class Popover extends PopoverPositionMixin(
688
719
 
689
720
  /** @private */
690
721
  __onGlobalTab(event) {
691
- const overlayPart = this._overlayElement.$.overlay;
692
-
693
- // Move focus to the popover content on target element Tab
722
+ // Move focus to the popover on target element Tab
694
723
  if (this.target && isElementFocused(this.__getTargetFocusable())) {
695
724
  event.preventDefault();
696
- overlayPart.focus();
725
+ this.focus();
697
726
  return;
698
727
  }
699
728
 
700
729
  // Move focus to the next element after target on content Tab
701
- const lastFocusable = this.__getLastFocusable(overlayPart);
730
+ const lastFocusable = this.__getLastFocusable(this);
702
731
  if (lastFocusable && isElementFocused(lastFocusable)) {
703
732
  const focusable = this.__getNextBodyFocusable(this.__getTargetFocusable());
704
- if (focusable && focusable !== overlayPart) {
733
+ if (focusable && focusable !== this) {
705
734
  event.preventDefault();
706
735
  focusable.focus();
707
736
  return;
@@ -711,7 +740,7 @@ class Popover extends PopoverPositionMixin(
711
740
  // Prevent focusing the popover content on previous element Tab
712
741
  const activeElement = getDeepActiveElement();
713
742
  const nextFocusable = this.__getNextBodyFocusable(activeElement);
714
- if (nextFocusable === overlayPart && lastFocusable) {
743
+ if (nextFocusable === this && lastFocusable) {
715
744
  // Move focus to the last overlay focusable and do NOT prevent keydown
716
745
  // to move focus outside the popover content (e.g. to the URL bar).
717
746
  lastFocusable.focus();
@@ -720,16 +749,14 @@ class Popover extends PopoverPositionMixin(
720
749
 
721
750
  /** @private */
722
751
  __onGlobalShiftTab(event) {
723
- const overlayPart = this._overlayElement.$.overlay;
724
-
725
752
  // Prevent restoring focus after target blur on Shift + Tab
726
753
  if (this.target && isElementFocused(this.__getTargetFocusable()) && this.__shouldRestoreFocus) {
727
754
  this.__shouldRestoreFocus = false;
728
755
  return;
729
756
  }
730
757
 
731
- // Move focus back to the target on overlay content Shift + Tab
732
- if (this.target && isElementFocused(overlayPart)) {
758
+ // Move focus back to the target on popover Shift + Tab
759
+ if (this.target && isElementFocused(this)) {
733
760
  event.preventDefault();
734
761
  this.__getTargetFocusable().focus();
735
762
  return;
@@ -738,7 +765,7 @@ class Popover extends PopoverPositionMixin(
738
765
  // Move focus back to the popover on next element Shift + Tab
739
766
  const nextFocusable = this.__getNextBodyFocusable(this.__getTargetFocusable());
740
767
  if (nextFocusable && isElementFocused(nextFocusable)) {
741
- const lastFocusable = this.__getLastFocusable(overlayPart);
768
+ const lastFocusable = this.__getLastFocusable(this);
742
769
  if (lastFocusable) {
743
770
  event.preventDefault();
744
771
  lastFocusable.focus();
@@ -834,7 +861,7 @@ class Popover extends PopoverPositionMixin(
834
861
  }
835
862
 
836
863
  /** @private */
837
- __onOverlayFocusIn() {
864
+ __onFocusIn() {
838
865
  this.__focusInside = true;
839
866
 
840
867
  // When using Tab to move focus, restoring focus is reset. However, if pressing Tab
@@ -845,7 +872,7 @@ class Popover extends PopoverPositionMixin(
845
872
  }
846
873
 
847
874
  /** @private */
848
- __onOverlayFocusOut(event) {
875
+ __onFocusOut(event) {
849
876
  // Do not close the popover on overlay focusout if it's not the last one.
850
877
  // This covers the following cases of nested overlay based components:
851
878
  // 1. Moving focus to the nested overlay (e.g. vaadin-select, vaadin-menu-bar)
@@ -857,7 +884,6 @@ class Popover extends PopoverPositionMixin(
857
884
  if (
858
885
  (this.__hasTrigger('focus') && this.__mouseDownInside) ||
859
886
  event.relatedTarget === this.target ||
860
- event.relatedTarget === this._overlayElement ||
861
887
  this.contains(event.relatedTarget)
862
888
  ) {
863
889
  return;
@@ -946,7 +972,7 @@ class Popover extends PopoverPositionMixin(
946
972
  /** @private */
947
973
  __onOverlayOpened() {
948
974
  if (this.autofocus && !this.modal) {
949
- this._overlayElement.$.overlay.focus();
975
+ this.focus();
950
976
  }
951
977
  }
952
978
 
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/popover",
4
- "version": "25.0.0-alpha15",
4
+ "version": "25.0.0-alpha16",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/popover",
4
- "version": "25.0.0-alpha15",
4
+ "version": "25.0.0-alpha16",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {