@vaadin/overlay 24.9.2 → 24.9.4
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 +9 -9
- package/src/vaadin-overlay-mixin.js +36 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/overlay",
|
|
3
|
-
"version": "24.9.
|
|
3
|
+
"version": "24.9.4",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -36,18 +36,18 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
38
38
|
"@polymer/polymer": "^3.0.0",
|
|
39
|
-
"@vaadin/a11y-base": "~24.9.
|
|
40
|
-
"@vaadin/component-base": "~24.9.
|
|
41
|
-
"@vaadin/vaadin-lumo-styles": "~24.9.
|
|
42
|
-
"@vaadin/vaadin-material-styles": "~24.9.
|
|
43
|
-
"@vaadin/vaadin-themable-mixin": "~24.9.
|
|
39
|
+
"@vaadin/a11y-base": "~24.9.4",
|
|
40
|
+
"@vaadin/component-base": "~24.9.4",
|
|
41
|
+
"@vaadin/vaadin-lumo-styles": "~24.9.4",
|
|
42
|
+
"@vaadin/vaadin-material-styles": "~24.9.4",
|
|
43
|
+
"@vaadin/vaadin-themable-mixin": "~24.9.4",
|
|
44
44
|
"lit": "^3.0.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@vaadin/chai-plugins": "~24.9.
|
|
48
|
-
"@vaadin/test-runner-commands": "~24.9.
|
|
47
|
+
"@vaadin/chai-plugins": "~24.9.4",
|
|
48
|
+
"@vaadin/test-runner-commands": "~24.9.4",
|
|
49
49
|
"@vaadin/testing-helpers": "^1.1.0",
|
|
50
50
|
"sinon": "^18.0.0"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "7084e972641ef2355ffc281cbd932c070f998ed1"
|
|
53
53
|
}
|
|
@@ -203,8 +203,25 @@ export const OverlayMixin = (superClass) =>
|
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
+
/**
|
|
207
|
+
* Whether to add global listeners for closing on outside click.
|
|
208
|
+
* By default, listeners are not added for a modeless overlay.
|
|
209
|
+
*
|
|
210
|
+
* @return {boolean}
|
|
211
|
+
* @protected
|
|
212
|
+
*/
|
|
213
|
+
_shouldAddGlobalListeners() {
|
|
214
|
+
return !this.modeless;
|
|
215
|
+
}
|
|
216
|
+
|
|
206
217
|
/** @private */
|
|
207
218
|
_addGlobalListeners() {
|
|
219
|
+
if (this.__hasGlobalListeners) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
this.__hasGlobalListeners = true;
|
|
224
|
+
|
|
208
225
|
document.addEventListener('mousedown', this._boundMouseDownListener);
|
|
209
226
|
document.addEventListener('mouseup', this._boundMouseUpListener);
|
|
210
227
|
// Firefox leaks click to document on contextmenu even if prevented
|
|
@@ -214,6 +231,12 @@ export const OverlayMixin = (superClass) =>
|
|
|
214
231
|
|
|
215
232
|
/** @private */
|
|
216
233
|
_removeGlobalListeners() {
|
|
234
|
+
if (!this.__hasGlobalListeners) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
this.__hasGlobalListeners = false;
|
|
239
|
+
|
|
217
240
|
document.removeEventListener('mousedown', this._boundMouseDownListener);
|
|
218
241
|
document.removeEventListener('mouseup', this._boundMouseUpListener);
|
|
219
242
|
document.documentElement.removeEventListener('click', this._boundOutsideClickListener, true);
|
|
@@ -247,13 +270,20 @@ export const OverlayMixin = (superClass) =>
|
|
|
247
270
|
|
|
248
271
|
/** @private */
|
|
249
272
|
_modelessChanged(modeless) {
|
|
273
|
+
if (this.opened) {
|
|
274
|
+
// Add / remove listeners if modeless is changed while opened
|
|
275
|
+
if (this._shouldAddGlobalListeners()) {
|
|
276
|
+
this._addGlobalListeners();
|
|
277
|
+
} else {
|
|
278
|
+
this._removeGlobalListeners();
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
250
282
|
if (!modeless) {
|
|
251
283
|
if (this.opened) {
|
|
252
|
-
this._addGlobalListeners();
|
|
253
284
|
this._enterModalState();
|
|
254
285
|
}
|
|
255
286
|
} else {
|
|
256
|
-
this._removeGlobalListeners();
|
|
257
287
|
this._exitModalState();
|
|
258
288
|
}
|
|
259
289
|
}
|
|
@@ -275,7 +305,7 @@ export const OverlayMixin = (superClass) =>
|
|
|
275
305
|
|
|
276
306
|
document.addEventListener('keydown', this._boundKeydownListener);
|
|
277
307
|
|
|
278
|
-
if (
|
|
308
|
+
if (this._shouldAddGlobalListeners()) {
|
|
279
309
|
this._addGlobalListeners();
|
|
280
310
|
}
|
|
281
311
|
} else if (wasOpened) {
|
|
@@ -290,7 +320,7 @@ export const OverlayMixin = (superClass) =>
|
|
|
290
320
|
|
|
291
321
|
document.removeEventListener('keydown', this._boundKeydownListener);
|
|
292
322
|
|
|
293
|
-
if (
|
|
323
|
+
if (this._shouldAddGlobalListeners()) {
|
|
294
324
|
this._removeGlobalListeners();
|
|
295
325
|
}
|
|
296
326
|
}
|
|
@@ -468,12 +498,12 @@ export const OverlayMixin = (superClass) =>
|
|
|
468
498
|
* @private
|
|
469
499
|
*/
|
|
470
500
|
_keydownListener(event) {
|
|
471
|
-
if (!this._last) {
|
|
501
|
+
if (!this._last || event.defaultPrevented) {
|
|
472
502
|
return;
|
|
473
503
|
}
|
|
474
504
|
|
|
475
505
|
// Only close modeless overlay on Esc press when it contains focus
|
|
476
|
-
if (this.
|
|
506
|
+
if (!this._shouldAddGlobalListeners() && !event.composedPath().includes(this.$.overlay)) {
|
|
477
507
|
return;
|
|
478
508
|
}
|
|
479
509
|
|