@vaadin/popover 25.0.0-alpha14 → 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 +10 -10
- package/src/lit/renderer-directives.d.ts +1 -0
- package/src/lit/renderer-directives.js +1 -0
- package/src/vaadin-popover-overlay.js +29 -3
- package/src/vaadin-popover.d.ts +17 -16
- package/src/vaadin-popover.js +62 -63
- package/web-types.json +19 -19
- package/web-types.lit.json +11 -11
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-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-
|
|
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-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-
|
|
48
|
-
"@vaadin/test-runner-commands": "25.0.0-
|
|
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-
|
|
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": "
|
|
57
|
+
"gitHead": "4b316158a4a4f702f032bc9940fc82f0faa840f4"
|
|
58
58
|
}
|
|
@@ -51,6 +51,7 @@ export class PopoverRendererDirective extends LitRendererDirective<Popover, Popo
|
|
|
51
51
|
* @param renderer the renderer callback that returns a Lit template.
|
|
52
52
|
* @param dependencies a single dependency or an array of dependencies
|
|
53
53
|
* which trigger a re-render when changed.
|
|
54
|
+
* @deprecated Add content elements as children of the popover using default slot
|
|
54
55
|
*/
|
|
55
56
|
export declare function popoverRenderer(
|
|
56
57
|
renderer: PopoverLitRenderer,
|
|
@@ -56,5 +56,6 @@ export class PopoverRendererDirective extends LitRendererDirective {
|
|
|
56
56
|
* @param renderer the renderer callback that returns a Lit template.
|
|
57
57
|
* @param dependencies a single dependency or an array of dependencies
|
|
58
58
|
* which trigger a re-render when changed.
|
|
59
|
+
* @deprecated Add content elements as children of the popover using default slot
|
|
59
60
|
*/
|
|
60
61
|
export const popoverRenderer = directive(PopoverRendererDirective);
|
|
@@ -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"
|
|
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,12 +69,38 @@ class PopoverOverlay extends PopoverOverlayMixin(
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
72
|
+
* Override method from OverlayFocusMixin to use owner as focus trap root
|
|
73
73
|
* @protected
|
|
74
|
+
* @override
|
|
74
75
|
*/
|
|
75
|
-
get
|
|
76
|
+
get _focusTrapRoot() {
|
|
76
77
|
return this.owner;
|
|
77
78
|
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Override method from `OverlayMixin` to always add outside
|
|
82
|
+
* click listener so that it can be used by modeless popover.
|
|
83
|
+
* @return {boolean}
|
|
84
|
+
* @protected
|
|
85
|
+
* @override
|
|
86
|
+
*/
|
|
87
|
+
_shouldAddGlobalListeners() {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Override method from `OverlayMixin` to prevent closing when clicking on target.
|
|
93
|
+
* Clicking the target will already close the popover when using the click trigger.
|
|
94
|
+
*
|
|
95
|
+
* @override
|
|
96
|
+
* @protected
|
|
97
|
+
*/
|
|
98
|
+
_shouldCloseOnOutsideClick(event) {
|
|
99
|
+
if (event.composedPath().includes(this.positionTarget)) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
return super._shouldCloseOnOutsideClick(event);
|
|
103
|
+
}
|
|
78
104
|
}
|
|
79
105
|
|
|
80
106
|
defineCustomElement(PopoverOverlay);
|
package/src/vaadin-popover.d.ts
CHANGED
|
@@ -109,13 +109,13 @@ declare class Popover extends PopoverPositionMixin(PopoverTargetMixin(ThemePrope
|
|
|
109
109
|
autofocus: boolean;
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
|
-
* Set the height of the
|
|
112
|
+
* Set the height of the popover.
|
|
113
113
|
* If a unitless number is provided, pixels are assumed.
|
|
114
114
|
*/
|
|
115
115
|
height: string | null;
|
|
116
116
|
|
|
117
117
|
/**
|
|
118
|
-
* Set the width of the
|
|
118
|
+
* Set the width of the popover.
|
|
119
119
|
* If a unitless number is provided, pixels are assumed.
|
|
120
120
|
*/
|
|
121
121
|
width: string | null;
|
|
@@ -152,12 +152,12 @@ declare class Popover extends PopoverPositionMixin(PopoverTargetMixin(ThemePrope
|
|
|
152
152
|
hoverDelay: number;
|
|
153
153
|
|
|
154
154
|
/**
|
|
155
|
-
* True if the popover
|
|
155
|
+
* True if the popover is visible and available for interaction.
|
|
156
156
|
*/
|
|
157
157
|
opened: boolean;
|
|
158
158
|
|
|
159
159
|
/**
|
|
160
|
-
* The `role` attribute value to be set on the
|
|
160
|
+
* The `role` attribute value to be set on the popover.
|
|
161
161
|
*
|
|
162
162
|
* @attr {string} overlay-role
|
|
163
163
|
* @deprecated Use standard `role` attribute on the popover instead
|
|
@@ -165,48 +165,47 @@ declare class Popover extends PopoverPositionMixin(PopoverTargetMixin(ThemePrope
|
|
|
165
165
|
overlayRole: string;
|
|
166
166
|
|
|
167
167
|
/**
|
|
168
|
-
* Custom function for rendering the content of the
|
|
168
|
+
* Custom function for rendering the content of the popover.
|
|
169
169
|
* Receives two arguments:
|
|
170
170
|
*
|
|
171
171
|
* - `root` The root container DOM element. Append your content to it.
|
|
172
|
-
* - `popover` The reference to the `vaadin-popover` element
|
|
172
|
+
* - `popover` The reference to the `vaadin-popover` element.
|
|
173
|
+
*
|
|
174
|
+
* @deprecated Add content elements as children of the popover using default slot
|
|
173
175
|
*/
|
|
174
176
|
renderer: PopoverRenderer | null | undefined;
|
|
175
177
|
|
|
176
178
|
/**
|
|
177
179
|
* When true, the popover prevents interacting with background elements
|
|
178
180
|
* by setting `pointer-events` style on the document body to `none`.
|
|
179
|
-
* This also enables trapping focus inside the
|
|
181
|
+
* This also enables trapping focus inside the popover.
|
|
180
182
|
*/
|
|
181
183
|
modal: boolean;
|
|
182
184
|
|
|
183
185
|
/**
|
|
184
|
-
* Set to true to disable closing popover
|
|
186
|
+
* Set to true to disable closing popover on outside click.
|
|
185
187
|
*
|
|
186
188
|
* @attr {boolean} no-close-on-outside-click
|
|
187
189
|
*/
|
|
188
190
|
noCloseOnOutsideClick: boolean;
|
|
189
191
|
|
|
190
192
|
/**
|
|
191
|
-
* Set to true to disable closing popover
|
|
192
|
-
* When the popover is modal, pressing Escape anywhere in the
|
|
193
|
-
* document closes the overlay. Otherwise, only Escape press
|
|
194
|
-
* from the popover itself or its target closes the overlay.
|
|
193
|
+
* Set to true to disable closing popover on Escape press.
|
|
195
194
|
*
|
|
196
195
|
* @attr {boolean} no-close-on-esc
|
|
197
196
|
*/
|
|
198
197
|
noCloseOnEsc: boolean;
|
|
199
198
|
|
|
200
199
|
/**
|
|
201
|
-
* Popover trigger mode, used to configure how the
|
|
200
|
+
* Popover trigger mode, used to configure how the popover is opened or closed.
|
|
202
201
|
* Could be set to multiple by providing an array, e.g. `trigger = ['hover', 'focus']`.
|
|
203
202
|
*
|
|
204
203
|
* Supported values:
|
|
205
204
|
* - `click` (default) - opens and closes on target click.
|
|
206
205
|
* - `hover` - opens on target mouseenter, closes on target mouseleave. Moving mouse
|
|
207
|
-
* to the popover
|
|
206
|
+
* to the popover content keeps the popover opened.
|
|
208
207
|
* - `focus` - opens on target focus, closes on target blur. Moving focus to the
|
|
209
|
-
* popover
|
|
208
|
+
* popover content keeps the popover opened.
|
|
210
209
|
*
|
|
211
210
|
* In addition to the behavior specified by `trigger`, the popover can be closed by:
|
|
212
211
|
* - pressing Escape key (unless `noCloseOnEsc` property is true)
|
|
@@ -219,7 +218,7 @@ declare class Popover extends PopoverPositionMixin(PopoverTargetMixin(ThemePrope
|
|
|
219
218
|
trigger: PopoverTrigger[] | null | undefined;
|
|
220
219
|
|
|
221
220
|
/**
|
|
222
|
-
* When true, the
|
|
221
|
+
* When true, the popover has a backdrop (modality curtain) on top of the
|
|
223
222
|
* underlying page content, covering the whole viewport.
|
|
224
223
|
*
|
|
225
224
|
* @attr {boolean} with-backdrop
|
|
@@ -231,6 +230,8 @@ declare class Popover extends PopoverPositionMixin(PopoverTargetMixin(ThemePrope
|
|
|
231
230
|
* While performing the update, it invokes the renderer passed in the `renderer` property.
|
|
232
231
|
*
|
|
233
232
|
* It is not guaranteed that the update happens immediately (synchronously) after it is requested.
|
|
233
|
+
*
|
|
234
|
+
* @deprecated Add content elements as children of the popover using default slot
|
|
234
235
|
*/
|
|
235
236
|
requestContentUpdate(): void;
|
|
236
237
|
|
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) ::part(overlay) {
|
|
232
|
+
outline: var(--vaadin-focus-ring-width) solid var(--vaadin-focus-ring-color);
|
|
220
233
|
}
|
|
221
234
|
`;
|
|
222
235
|
}
|
|
@@ -252,7 +265,7 @@ class Popover extends PopoverPositionMixin(
|
|
|
252
265
|
},
|
|
253
266
|
|
|
254
267
|
/**
|
|
255
|
-
* Set the height of the
|
|
268
|
+
* Set the height of the popover.
|
|
256
269
|
* If a unitless number is provided, pixels are assumed.
|
|
257
270
|
*/
|
|
258
271
|
height: {
|
|
@@ -260,7 +273,7 @@ class Popover extends PopoverPositionMixin(
|
|
|
260
273
|
},
|
|
261
274
|
|
|
262
275
|
/**
|
|
263
|
-
* Set the width of the
|
|
276
|
+
* Set the width of the popover.
|
|
264
277
|
* If a unitless number is provided, pixels are assumed.
|
|
265
278
|
*/
|
|
266
279
|
width: {
|
|
@@ -305,7 +318,7 @@ class Popover extends PopoverPositionMixin(
|
|
|
305
318
|
},
|
|
306
319
|
|
|
307
320
|
/**
|
|
308
|
-
* True if the popover
|
|
321
|
+
* True if the popover is visible and available for interaction.
|
|
309
322
|
*/
|
|
310
323
|
opened: {
|
|
311
324
|
type: Boolean,
|
|
@@ -325,7 +338,7 @@ class Popover extends PopoverPositionMixin(
|
|
|
325
338
|
},
|
|
326
339
|
|
|
327
340
|
/**
|
|
328
|
-
* The `role` attribute value to be set on the
|
|
341
|
+
* The `role` attribute value to be set on the popover.
|
|
329
342
|
*
|
|
330
343
|
* @attr {string} overlay-role
|
|
331
344
|
* @deprecated Use standard `role` attribute on the popover instead
|
|
@@ -335,11 +348,13 @@ class Popover extends PopoverPositionMixin(
|
|
|
335
348
|
},
|
|
336
349
|
|
|
337
350
|
/**
|
|
338
|
-
* Custom function for rendering the content of the
|
|
351
|
+
* Custom function for rendering the content of the popover.
|
|
339
352
|
* Receives two arguments:
|
|
340
353
|
*
|
|
341
354
|
* - `root` The root container DOM element. Append your content to it.
|
|
342
|
-
* - `popover` The reference to the `vaadin-popover` element
|
|
355
|
+
* - `popover` The reference to the `vaadin-popover` element.
|
|
356
|
+
*
|
|
357
|
+
* @deprecated Use the content in the `vaadin-popover` via default slot
|
|
343
358
|
*/
|
|
344
359
|
renderer: {
|
|
345
360
|
type: Object,
|
|
@@ -348,7 +363,7 @@ class Popover extends PopoverPositionMixin(
|
|
|
348
363
|
/**
|
|
349
364
|
* When true, the popover prevents interacting with background elements
|
|
350
365
|
* by setting `pointer-events` style on the document body to `none`.
|
|
351
|
-
* This also enables trapping focus inside the
|
|
366
|
+
* This also enables trapping focus inside the popover.
|
|
352
367
|
*/
|
|
353
368
|
modal: {
|
|
354
369
|
type: Boolean,
|
|
@@ -356,7 +371,7 @@ class Popover extends PopoverPositionMixin(
|
|
|
356
371
|
},
|
|
357
372
|
|
|
358
373
|
/**
|
|
359
|
-
* Set to true to disable closing popover
|
|
374
|
+
* Set to true to disable closing popover on outside click.
|
|
360
375
|
*
|
|
361
376
|
* @attr {boolean} no-close-on-outside-click
|
|
362
377
|
*/
|
|
@@ -366,10 +381,7 @@ class Popover extends PopoverPositionMixin(
|
|
|
366
381
|
},
|
|
367
382
|
|
|
368
383
|
/**
|
|
369
|
-
* Set to true to disable closing popover
|
|
370
|
-
* When the popover is modal, pressing Escape anywhere in the
|
|
371
|
-
* document closes the overlay. Otherwise, only Escape press
|
|
372
|
-
* from the popover itself or its target closes the overlay.
|
|
384
|
+
* Set to true to disable closing popover on Escape press.
|
|
373
385
|
*
|
|
374
386
|
* @attr {boolean} no-close-on-esc
|
|
375
387
|
*/
|
|
@@ -379,15 +391,15 @@ class Popover extends PopoverPositionMixin(
|
|
|
379
391
|
},
|
|
380
392
|
|
|
381
393
|
/**
|
|
382
|
-
* Popover trigger mode, used to configure how the
|
|
394
|
+
* Popover trigger mode, used to configure how the popover is opened or closed.
|
|
383
395
|
* Could be set to multiple by providing an array, e.g. `trigger = ['hover', 'focus']`.
|
|
384
396
|
*
|
|
385
397
|
* Supported values:
|
|
386
398
|
* - `click` (default) - opens and closes on target click.
|
|
387
399
|
* - `hover` - opens on target mouseenter, closes on target mouseleave. Moving mouse
|
|
388
|
-
* to the popover
|
|
400
|
+
* to the popover content keeps the popover opened.
|
|
389
401
|
* - `focus` - opens on target focus, closes on target blur. Moving focus to the
|
|
390
|
-
* popover
|
|
402
|
+
* popover content keeps the popover opened.
|
|
391
403
|
*
|
|
392
404
|
* In addition to the behavior specified by `trigger`, the popover can be closed by:
|
|
393
405
|
* - pressing Escape key (unless `noCloseOnEsc` property is true)
|
|
@@ -403,7 +415,7 @@ class Popover extends PopoverPositionMixin(
|
|
|
403
415
|
},
|
|
404
416
|
|
|
405
417
|
/**
|
|
406
|
-
* When true, the
|
|
418
|
+
* When true, the popover has a backdrop (modality curtain) on top of the
|
|
407
419
|
* underlying page content, covering the whole viewport.
|
|
408
420
|
*
|
|
409
421
|
* @attr {boolean} with-backdrop
|
|
@@ -461,7 +473,6 @@ class Popover extends PopoverPositionMixin(
|
|
|
461
473
|
|
|
462
474
|
this.__generatedId = `vaadin-popover-${generateUniqueId()}`;
|
|
463
475
|
|
|
464
|
-
this.__onGlobalClick = this.__onGlobalClick.bind(this);
|
|
465
476
|
this.__onGlobalKeyDown = this.__onGlobalKeyDown.bind(this);
|
|
466
477
|
this.__onTargetClick = this.__onTargetClick.bind(this);
|
|
467
478
|
this.__onTargetFocusIn = this.__onTargetFocusIn.bind(this);
|
|
@@ -516,6 +527,8 @@ class Popover extends PopoverPositionMixin(
|
|
|
516
527
|
* While performing the update, it invokes the renderer passed in the `renderer` property.
|
|
517
528
|
*
|
|
518
529
|
* It is not guaranteed that the update happens immediately (synchronously) after it is requested.
|
|
530
|
+
*
|
|
531
|
+
* @deprecated Add content elements as children of the popover using default slot
|
|
519
532
|
*/
|
|
520
533
|
requestContentUpdate() {
|
|
521
534
|
if (!this.renderer || !this._overlayElement) {
|
|
@@ -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 */
|
|
@@ -574,16 +605,12 @@ class Popover extends PopoverPositionMixin(
|
|
|
574
605
|
if (!this.id) {
|
|
575
606
|
this.id = this.__generatedId;
|
|
576
607
|
}
|
|
577
|
-
|
|
578
|
-
document.documentElement.addEventListener('click', this.__onGlobalClick, true);
|
|
579
608
|
}
|
|
580
609
|
|
|
581
610
|
/** @protected */
|
|
582
611
|
disconnectedCallback() {
|
|
583
612
|
super.disconnectedCallback();
|
|
584
613
|
|
|
585
|
-
document.documentElement.removeEventListener('click', this.__onGlobalClick, true);
|
|
586
|
-
|
|
587
614
|
// Automatically close popover when it is removed from DOM
|
|
588
615
|
// Avoid closing if the popover is just moved in the DOM
|
|
589
616
|
queueMicrotask(() => {
|
|
@@ -655,23 +682,6 @@ class Popover extends PopoverPositionMixin(
|
|
|
655
682
|
}
|
|
656
683
|
}
|
|
657
684
|
|
|
658
|
-
/**
|
|
659
|
-
* Overlay's global outside click listener doesn't work when
|
|
660
|
-
* the overlay is modeless, so we use a separate listener.
|
|
661
|
-
* @private
|
|
662
|
-
*/
|
|
663
|
-
__onGlobalClick(event) {
|
|
664
|
-
if (
|
|
665
|
-
this.opened &&
|
|
666
|
-
!this.modal &&
|
|
667
|
-
!event.composedPath().some((el) => el === this._overlayElement || el === this.target) &&
|
|
668
|
-
!this.noCloseOnOutsideClick &&
|
|
669
|
-
isLastOverlay(this._overlayElement)
|
|
670
|
-
) {
|
|
671
|
-
this._openedStateController.close(true);
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
|
|
675
685
|
/** @private */
|
|
676
686
|
__onTargetClick() {
|
|
677
687
|
if (this.__hasTrigger('click')) {
|
|
@@ -692,17 +702,11 @@ class Popover extends PopoverPositionMixin(
|
|
|
692
702
|
* @private
|
|
693
703
|
*/
|
|
694
704
|
__onGlobalKeyDown(event) {
|
|
695
|
-
// Modal popover uses overlay logic
|
|
705
|
+
// Modal popover uses overlay logic focus trap.
|
|
696
706
|
if (this.modal) {
|
|
697
707
|
return;
|
|
698
708
|
}
|
|
699
709
|
|
|
700
|
-
if (event.key === 'Escape' && !this.noCloseOnEsc && this.opened && isLastOverlay(this._overlayElement)) {
|
|
701
|
-
// Prevent closing parent overlay (e.g. dialog)
|
|
702
|
-
event.stopPropagation();
|
|
703
|
-
this._openedStateController.close(true);
|
|
704
|
-
}
|
|
705
|
-
|
|
706
710
|
// Include popover content in the Tab order after the target.
|
|
707
711
|
if (event.key === 'Tab') {
|
|
708
712
|
if (event.shiftKey) {
|
|
@@ -715,20 +719,18 @@ class Popover extends PopoverPositionMixin(
|
|
|
715
719
|
|
|
716
720
|
/** @private */
|
|
717
721
|
__onGlobalTab(event) {
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
// Move focus to the popover content on target element Tab
|
|
722
|
+
// Move focus to the popover on target element Tab
|
|
721
723
|
if (this.target && isElementFocused(this.__getTargetFocusable())) {
|
|
722
724
|
event.preventDefault();
|
|
723
|
-
|
|
725
|
+
this.focus();
|
|
724
726
|
return;
|
|
725
727
|
}
|
|
726
728
|
|
|
727
729
|
// Move focus to the next element after target on content Tab
|
|
728
|
-
const lastFocusable = this.__getLastFocusable(
|
|
730
|
+
const lastFocusable = this.__getLastFocusable(this);
|
|
729
731
|
if (lastFocusable && isElementFocused(lastFocusable)) {
|
|
730
732
|
const focusable = this.__getNextBodyFocusable(this.__getTargetFocusable());
|
|
731
|
-
if (focusable && focusable !==
|
|
733
|
+
if (focusable && focusable !== this) {
|
|
732
734
|
event.preventDefault();
|
|
733
735
|
focusable.focus();
|
|
734
736
|
return;
|
|
@@ -738,7 +740,7 @@ class Popover extends PopoverPositionMixin(
|
|
|
738
740
|
// Prevent focusing the popover content on previous element Tab
|
|
739
741
|
const activeElement = getDeepActiveElement();
|
|
740
742
|
const nextFocusable = this.__getNextBodyFocusable(activeElement);
|
|
741
|
-
if (nextFocusable ===
|
|
743
|
+
if (nextFocusable === this && lastFocusable) {
|
|
742
744
|
// Move focus to the last overlay focusable and do NOT prevent keydown
|
|
743
745
|
// to move focus outside the popover content (e.g. to the URL bar).
|
|
744
746
|
lastFocusable.focus();
|
|
@@ -747,16 +749,14 @@ class Popover extends PopoverPositionMixin(
|
|
|
747
749
|
|
|
748
750
|
/** @private */
|
|
749
751
|
__onGlobalShiftTab(event) {
|
|
750
|
-
const overlayPart = this._overlayElement.$.overlay;
|
|
751
|
-
|
|
752
752
|
// Prevent restoring focus after target blur on Shift + Tab
|
|
753
753
|
if (this.target && isElementFocused(this.__getTargetFocusable()) && this.__shouldRestoreFocus) {
|
|
754
754
|
this.__shouldRestoreFocus = false;
|
|
755
755
|
return;
|
|
756
756
|
}
|
|
757
757
|
|
|
758
|
-
// Move focus back to the target on
|
|
759
|
-
if (this.target && isElementFocused(
|
|
758
|
+
// Move focus back to the target on popover Shift + Tab
|
|
759
|
+
if (this.target && isElementFocused(this)) {
|
|
760
760
|
event.preventDefault();
|
|
761
761
|
this.__getTargetFocusable().focus();
|
|
762
762
|
return;
|
|
@@ -765,7 +765,7 @@ class Popover extends PopoverPositionMixin(
|
|
|
765
765
|
// Move focus back to the popover on next element Shift + Tab
|
|
766
766
|
const nextFocusable = this.__getNextBodyFocusable(this.__getTargetFocusable());
|
|
767
767
|
if (nextFocusable && isElementFocused(nextFocusable)) {
|
|
768
|
-
const lastFocusable = this.__getLastFocusable(
|
|
768
|
+
const lastFocusable = this.__getLastFocusable(this);
|
|
769
769
|
if (lastFocusable) {
|
|
770
770
|
event.preventDefault();
|
|
771
771
|
lastFocusable.focus();
|
|
@@ -861,7 +861,7 @@ class Popover extends PopoverPositionMixin(
|
|
|
861
861
|
}
|
|
862
862
|
|
|
863
863
|
/** @private */
|
|
864
|
-
|
|
864
|
+
__onFocusIn() {
|
|
865
865
|
this.__focusInside = true;
|
|
866
866
|
|
|
867
867
|
// When using Tab to move focus, restoring focus is reset. However, if pressing Tab
|
|
@@ -872,7 +872,7 @@ class Popover extends PopoverPositionMixin(
|
|
|
872
872
|
}
|
|
873
873
|
|
|
874
874
|
/** @private */
|
|
875
|
-
|
|
875
|
+
__onFocusOut(event) {
|
|
876
876
|
// Do not close the popover on overlay focusout if it's not the last one.
|
|
877
877
|
// This covers the following cases of nested overlay based components:
|
|
878
878
|
// 1. Moving focus to the nested overlay (e.g. vaadin-select, vaadin-menu-bar)
|
|
@@ -884,7 +884,6 @@ class Popover extends PopoverPositionMixin(
|
|
|
884
884
|
if (
|
|
885
885
|
(this.__hasTrigger('focus') && this.__mouseDownInside) ||
|
|
886
886
|
event.relatedTarget === this.target ||
|
|
887
|
-
event.relatedTarget === this._overlayElement ||
|
|
888
887
|
this.contains(event.relatedTarget)
|
|
889
888
|
) {
|
|
890
889
|
return;
|
|
@@ -973,7 +972,7 @@ class Popover extends PopoverPositionMixin(
|
|
|
973
972
|
/** @private */
|
|
974
973
|
__onOverlayOpened() {
|
|
975
974
|
if (this.autofocus && !this.modal) {
|
|
976
|
-
this.
|
|
975
|
+
this.focus();
|
|
977
976
|
}
|
|
978
977
|
}
|
|
979
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-
|
|
4
|
+
"version": "25.0.0-alpha16",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
},
|
|
68
68
|
{
|
|
69
69
|
"name": "height",
|
|
70
|
-
"description": "Set the height of the
|
|
70
|
+
"description": "Set the height of the popover.\nIf a unitless number is provided, pixels are assumed.",
|
|
71
71
|
"value": {
|
|
72
72
|
"type": [
|
|
73
73
|
"string",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
80
|
"name": "width",
|
|
81
|
-
"description": "Set the width of the
|
|
81
|
+
"description": "Set the width of the popover.\nIf a unitless number is provided, pixels are assumed.",
|
|
82
82
|
"value": {
|
|
83
83
|
"type": [
|
|
84
84
|
"string",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
},
|
|
123
123
|
{
|
|
124
124
|
"name": "opened",
|
|
125
|
-
"description": "True if the popover
|
|
125
|
+
"description": "True if the popover is visible and available for interaction.",
|
|
126
126
|
"value": {
|
|
127
127
|
"type": [
|
|
128
128
|
"boolean",
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
},
|
|
145
145
|
{
|
|
146
146
|
"name": "overlay-role",
|
|
147
|
-
"description": "The `role` attribute value to be set on the
|
|
147
|
+
"description": "The `role` attribute value to be set on the popover.",
|
|
148
148
|
"value": {
|
|
149
149
|
"type": [
|
|
150
150
|
"string",
|
|
@@ -155,7 +155,7 @@
|
|
|
155
155
|
},
|
|
156
156
|
{
|
|
157
157
|
"name": "modal",
|
|
158
|
-
"description": "When true, the popover prevents interacting with background elements\nby setting `pointer-events` style on the document body to `none`.\nThis also enables trapping focus inside the
|
|
158
|
+
"description": "When true, the popover prevents interacting with background elements\nby setting `pointer-events` style on the document body to `none`.\nThis also enables trapping focus inside the popover.",
|
|
159
159
|
"value": {
|
|
160
160
|
"type": [
|
|
161
161
|
"boolean",
|
|
@@ -166,7 +166,7 @@
|
|
|
166
166
|
},
|
|
167
167
|
{
|
|
168
168
|
"name": "no-close-on-outside-click",
|
|
169
|
-
"description": "Set to true to disable closing popover
|
|
169
|
+
"description": "Set to true to disable closing popover on outside click.",
|
|
170
170
|
"value": {
|
|
171
171
|
"type": [
|
|
172
172
|
"boolean",
|
|
@@ -177,7 +177,7 @@
|
|
|
177
177
|
},
|
|
178
178
|
{
|
|
179
179
|
"name": "no-close-on-esc",
|
|
180
|
-
"description": "Set to true to disable closing popover
|
|
180
|
+
"description": "Set to true to disable closing popover on Escape press.",
|
|
181
181
|
"value": {
|
|
182
182
|
"type": [
|
|
183
183
|
"boolean",
|
|
@@ -188,7 +188,7 @@
|
|
|
188
188
|
},
|
|
189
189
|
{
|
|
190
190
|
"name": "with-backdrop",
|
|
191
|
-
"description": "When true, the
|
|
191
|
+
"description": "When true, the popover has a backdrop (modality curtain) on top of the\nunderlying page content, covering the whole viewport.",
|
|
192
192
|
"value": {
|
|
193
193
|
"type": [
|
|
194
194
|
"boolean",
|
|
@@ -279,7 +279,7 @@
|
|
|
279
279
|
},
|
|
280
280
|
{
|
|
281
281
|
"name": "height",
|
|
282
|
-
"description": "Set the height of the
|
|
282
|
+
"description": "Set the height of the popover.\nIf a unitless number is provided, pixels are assumed.",
|
|
283
283
|
"value": {
|
|
284
284
|
"type": [
|
|
285
285
|
"string",
|
|
@@ -290,7 +290,7 @@
|
|
|
290
290
|
},
|
|
291
291
|
{
|
|
292
292
|
"name": "width",
|
|
293
|
-
"description": "Set the width of the
|
|
293
|
+
"description": "Set the width of the popover.\nIf a unitless number is provided, pixels are assumed.",
|
|
294
294
|
"value": {
|
|
295
295
|
"type": [
|
|
296
296
|
"string",
|
|
@@ -334,7 +334,7 @@
|
|
|
334
334
|
},
|
|
335
335
|
{
|
|
336
336
|
"name": "opened",
|
|
337
|
-
"description": "True if the popover
|
|
337
|
+
"description": "True if the popover is visible and available for interaction.",
|
|
338
338
|
"value": {
|
|
339
339
|
"type": [
|
|
340
340
|
"boolean",
|
|
@@ -356,7 +356,7 @@
|
|
|
356
356
|
},
|
|
357
357
|
{
|
|
358
358
|
"name": "overlayRole",
|
|
359
|
-
"description": "The `role` attribute value to be set on the
|
|
359
|
+
"description": "The `role` attribute value to be set on the popover.",
|
|
360
360
|
"value": {
|
|
361
361
|
"type": [
|
|
362
362
|
"string",
|
|
@@ -367,7 +367,7 @@
|
|
|
367
367
|
},
|
|
368
368
|
{
|
|
369
369
|
"name": "renderer",
|
|
370
|
-
"description": "Custom function for rendering the content of the
|
|
370
|
+
"description": "Custom function for rendering the content of the popover.\nReceives two arguments:\n\n- `root` The root container DOM element. Append your content to it.\n- `popover` The reference to the `vaadin-popover` element.",
|
|
371
371
|
"value": {
|
|
372
372
|
"type": [
|
|
373
373
|
"Object",
|
|
@@ -378,7 +378,7 @@
|
|
|
378
378
|
},
|
|
379
379
|
{
|
|
380
380
|
"name": "modal",
|
|
381
|
-
"description": "When true, the popover prevents interacting with background elements\nby setting `pointer-events` style on the document body to `none`.\nThis also enables trapping focus inside the
|
|
381
|
+
"description": "When true, the popover prevents interacting with background elements\nby setting `pointer-events` style on the document body to `none`.\nThis also enables trapping focus inside the popover.",
|
|
382
382
|
"value": {
|
|
383
383
|
"type": [
|
|
384
384
|
"boolean",
|
|
@@ -389,7 +389,7 @@
|
|
|
389
389
|
},
|
|
390
390
|
{
|
|
391
391
|
"name": "noCloseOnOutsideClick",
|
|
392
|
-
"description": "Set to true to disable closing popover
|
|
392
|
+
"description": "Set to true to disable closing popover on outside click.",
|
|
393
393
|
"value": {
|
|
394
394
|
"type": [
|
|
395
395
|
"boolean",
|
|
@@ -400,7 +400,7 @@
|
|
|
400
400
|
},
|
|
401
401
|
{
|
|
402
402
|
"name": "noCloseOnEsc",
|
|
403
|
-
"description": "Set to true to disable closing popover
|
|
403
|
+
"description": "Set to true to disable closing popover on Escape press.",
|
|
404
404
|
"value": {
|
|
405
405
|
"type": [
|
|
406
406
|
"boolean",
|
|
@@ -411,7 +411,7 @@
|
|
|
411
411
|
},
|
|
412
412
|
{
|
|
413
413
|
"name": "trigger",
|
|
414
|
-
"description": "Popover trigger mode, used to configure how the
|
|
414
|
+
"description": "Popover trigger mode, used to configure how the popover is opened or closed.\nCould be set to multiple by providing an array, e.g. `trigger = ['hover', 'focus']`.\n\nSupported values:\n- `click` (default) - opens and closes on target click.\n- `hover` - opens on target mouseenter, closes on target mouseleave. Moving mouse\nto the popover content keeps the popover opened.\n- `focus` - opens on target focus, closes on target blur. Moving focus to the\npopover content keeps the popover opened.\n\nIn addition to the behavior specified by `trigger`, the popover can be closed by:\n- pressing Escape key (unless `noCloseOnEsc` property is true)\n- outside click (unless `noCloseOnOutsideClick` property is true)\n\nWhen setting `trigger` property to `null`, `undefined` or empty array, the popover\ncan be only opened programmatically by changing `opened` property. Note, closing\non Escape press or outside click is still allowed unless explicitly disabled.",
|
|
415
415
|
"value": {
|
|
416
416
|
"type": [
|
|
417
417
|
"Array",
|
|
@@ -422,7 +422,7 @@
|
|
|
422
422
|
},
|
|
423
423
|
{
|
|
424
424
|
"name": "withBackdrop",
|
|
425
|
-
"description": "When true, the
|
|
425
|
+
"description": "When true, the popover has a backdrop (modality curtain) on top of the\nunderlying page content, covering the whole viewport.",
|
|
426
426
|
"value": {
|
|
427
427
|
"type": [
|
|
428
428
|
"boolean",
|
package/web-types.lit.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-
|
|
4
|
+
"version": "25.0.0-alpha16",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -28,35 +28,35 @@
|
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
30
|
"name": "?opened",
|
|
31
|
-
"description": "True if the popover
|
|
31
|
+
"description": "True if the popover is visible and available for interaction.",
|
|
32
32
|
"value": {
|
|
33
33
|
"kind": "expression"
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
37
|
"name": "?modal",
|
|
38
|
-
"description": "When true, the popover prevents interacting with background elements\nby setting `pointer-events` style on the document body to `none`.\nThis also enables trapping focus inside the
|
|
38
|
+
"description": "When true, the popover prevents interacting with background elements\nby setting `pointer-events` style on the document body to `none`.\nThis also enables trapping focus inside the popover.",
|
|
39
39
|
"value": {
|
|
40
40
|
"kind": "expression"
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
44
|
"name": "?noCloseOnOutsideClick",
|
|
45
|
-
"description": "Set to true to disable closing popover
|
|
45
|
+
"description": "Set to true to disable closing popover on outside click.",
|
|
46
46
|
"value": {
|
|
47
47
|
"kind": "expression"
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
"name": "?noCloseOnEsc",
|
|
52
|
-
"description": "Set to true to disable closing popover
|
|
52
|
+
"description": "Set to true to disable closing popover on Escape press.",
|
|
53
53
|
"value": {
|
|
54
54
|
"kind": "expression"
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
"name": "?withBackdrop",
|
|
59
|
-
"description": "When true, the
|
|
59
|
+
"description": "When true, the popover has a backdrop (modality curtain) on top of the\nunderlying page content, covering the whole viewport.",
|
|
60
60
|
"value": {
|
|
61
61
|
"kind": "expression"
|
|
62
62
|
}
|
|
@@ -98,14 +98,14 @@
|
|
|
98
98
|
},
|
|
99
99
|
{
|
|
100
100
|
"name": ".height",
|
|
101
|
-
"description": "Set the height of the
|
|
101
|
+
"description": "Set the height of the popover.\nIf a unitless number is provided, pixels are assumed.",
|
|
102
102
|
"value": {
|
|
103
103
|
"kind": "expression"
|
|
104
104
|
}
|
|
105
105
|
},
|
|
106
106
|
{
|
|
107
107
|
"name": ".width",
|
|
108
|
-
"description": "Set the width of the
|
|
108
|
+
"description": "Set the width of the popover.\nIf a unitless number is provided, pixels are assumed.",
|
|
109
109
|
"value": {
|
|
110
110
|
"kind": "expression"
|
|
111
111
|
}
|
|
@@ -140,21 +140,21 @@
|
|
|
140
140
|
},
|
|
141
141
|
{
|
|
142
142
|
"name": ".overlayRole",
|
|
143
|
-
"description": "The `role` attribute value to be set on the
|
|
143
|
+
"description": "The `role` attribute value to be set on the popover.",
|
|
144
144
|
"value": {
|
|
145
145
|
"kind": "expression"
|
|
146
146
|
}
|
|
147
147
|
},
|
|
148
148
|
{
|
|
149
149
|
"name": ".renderer",
|
|
150
|
-
"description": "Custom function for rendering the content of the
|
|
150
|
+
"description": "Custom function for rendering the content of the popover.\nReceives two arguments:\n\n- `root` The root container DOM element. Append your content to it.\n- `popover` The reference to the `vaadin-popover` element.",
|
|
151
151
|
"value": {
|
|
152
152
|
"kind": "expression"
|
|
153
153
|
}
|
|
154
154
|
},
|
|
155
155
|
{
|
|
156
156
|
"name": ".trigger",
|
|
157
|
-
"description": "Popover trigger mode, used to configure how the
|
|
157
|
+
"description": "Popover trigger mode, used to configure how the popover is opened or closed.\nCould be set to multiple by providing an array, e.g. `trigger = ['hover', 'focus']`.\n\nSupported values:\n- `click` (default) - opens and closes on target click.\n- `hover` - opens on target mouseenter, closes on target mouseleave. Moving mouse\nto the popover content keeps the popover opened.\n- `focus` - opens on target focus, closes on target blur. Moving focus to the\npopover content keeps the popover opened.\n\nIn addition to the behavior specified by `trigger`, the popover can be closed by:\n- pressing Escape key (unless `noCloseOnEsc` property is true)\n- outside click (unless `noCloseOnOutsideClick` property is true)\n\nWhen setting `trigger` property to `null`, `undefined` or empty array, the popover\ncan be only opened programmatically by changing `opened` property. Note, closing\non Escape press or outside click is still allowed unless explicitly disabled.",
|
|
158
158
|
"value": {
|
|
159
159
|
"kind": "expression"
|
|
160
160
|
}
|