@vaadin/overlay 25.4.0-dev.55bb86e155 → 25.4.0-rc1
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/custom-elements.json
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"type": {
|
|
34
34
|
"text": "boolean"
|
|
35
35
|
},
|
|
36
|
-
"description": "Set to true to move focus into the overlay automatically on open.\n\nFocus moves to the first tabbable element in the tab order. This\ncan be the overlay itself if it has `tabindex` attribute set to `0`\non the host element or the `overlay` shadow DOM part.",
|
|
36
|
+
"description": "Set to true to move focus into the overlay automatically on open.\n\nFocus moves to the first tabbable element in the tab order. This\ncan be the overlay itself if it has `tabindex` attribute set to `0`\non the host element or the `overlay` shadow DOM part.\n\nAn element inside the overlay that has `autofocus` set, such as\n`<vaadin-text-field autofocus>`, receives focus on open instead,\neven when this property is false.",
|
|
37
37
|
"attribute": "autofocus"
|
|
38
38
|
},
|
|
39
39
|
{
|
|
@@ -53,8 +53,7 @@
|
|
|
53
53
|
"type": {
|
|
54
54
|
"text": "HTMLElement"
|
|
55
55
|
},
|
|
56
|
-
"description": "Set to specify the element which should be focused on overlay close,\nif `restoreFocusOnClose` is set to true."
|
|
57
|
-
"attribute": "restore-focus-node"
|
|
56
|
+
"description": "Set to specify the element which should be focused on overlay close,\nif `restoreFocusOnClose` is set to true."
|
|
58
57
|
},
|
|
59
58
|
{
|
|
60
59
|
"kind": "field",
|
|
@@ -73,7 +72,7 @@
|
|
|
73
72
|
"type": {
|
|
74
73
|
"text": "boolean"
|
|
75
74
|
},
|
|
76
|
-
"description": "Set to true to move focus into the overlay automatically on open.\n\nFocus moves to the first tabbable element in the tab order. This\ncan be the overlay itself if it has `tabindex` attribute set to `0`\non the host element or the `overlay` shadow DOM part.",
|
|
75
|
+
"description": "Set to true to move focus into the overlay automatically on open.\n\nFocus moves to the first tabbable element in the tab order. This\ncan be the overlay itself if it has `tabindex` attribute set to `0`\non the host element or the `overlay` shadow DOM part.\n\nAn element inside the overlay that has `autofocus` set, such as\n`<vaadin-text-field autofocus>`, receives focus on open instead,\neven when this property is false.",
|
|
77
76
|
"fieldName": "autofocus"
|
|
78
77
|
},
|
|
79
78
|
{
|
|
@@ -84,14 +83,6 @@
|
|
|
84
83
|
"description": "Set to true to move focus into the overlay automatically on open\nand keep it inside: Tab and Shift+Tab cycle through the overlay's\ncontent until the overlay is closed.\n\nFocus moves to the first tabbable element in the tab order. This\ncan be the overlay itself if it has `tabindex` attribute set to `0`\non the host element or the `overlay` shadow DOM part.",
|
|
85
84
|
"fieldName": "focusTrap"
|
|
86
85
|
},
|
|
87
|
-
{
|
|
88
|
-
"name": "restore-focus-node",
|
|
89
|
-
"type": {
|
|
90
|
-
"text": "HTMLElement"
|
|
91
|
-
},
|
|
92
|
-
"description": "Set to specify the element which should be focused on overlay close,\nif `restoreFocusOnClose` is set to true.",
|
|
93
|
-
"fieldName": "restoreFocusNode"
|
|
94
|
-
},
|
|
95
86
|
{
|
|
96
87
|
"name": "restore-focus-on-close",
|
|
97
88
|
"type": {
|
|
@@ -135,7 +126,7 @@
|
|
|
135
126
|
"type": {
|
|
136
127
|
"text": "boolean"
|
|
137
128
|
},
|
|
138
|
-
"description": "Set to true to move focus into the overlay automatically on open.\n\nFocus moves to the first tabbable element in the tab order. This\ncan be the overlay itself if it has `tabindex` attribute set to `0`\non the host element or the `overlay` shadow DOM part.",
|
|
129
|
+
"description": "Set to true to move focus into the overlay automatically on open.\n\nFocus moves to the first tabbable element in the tab order. This\ncan be the overlay itself if it has `tabindex` attribute set to `0`\non the host element or the `overlay` shadow DOM part.\n\nAn element inside the overlay that has `autofocus` set, such as\n`<vaadin-text-field autofocus>`, receives focus on open instead,\neven when this property is false.",
|
|
139
130
|
"attribute": "autofocus",
|
|
140
131
|
"inheritedFrom": {
|
|
141
132
|
"name": "OverlayFocusMixin",
|
|
@@ -194,8 +185,7 @@
|
|
|
194
185
|
"type": {
|
|
195
186
|
"text": "object"
|
|
196
187
|
},
|
|
197
|
-
"description": "Object with properties that is passed to `renderer` function"
|
|
198
|
-
"attribute": "model"
|
|
188
|
+
"description": "Object with properties that is passed to `renderer` function"
|
|
199
189
|
},
|
|
200
190
|
{
|
|
201
191
|
"kind": "field",
|
|
@@ -224,8 +214,7 @@
|
|
|
224
214
|
"type": {
|
|
225
215
|
"text": "HTMLElement"
|
|
226
216
|
},
|
|
227
|
-
"description": "Owner element passed with renderer function"
|
|
228
|
-
"attribute": "owner"
|
|
217
|
+
"description": "Owner element passed with renderer function"
|
|
229
218
|
},
|
|
230
219
|
{
|
|
231
220
|
"kind": "field",
|
|
@@ -234,8 +223,7 @@
|
|
|
234
223
|
"type": {
|
|
235
224
|
"text": "OverlayRenderer | null | undefined"
|
|
236
225
|
},
|
|
237
|
-
"description": "Custom function for rendering the content of the overlay.\nReceives three arguments:\n\n- `root` The root container DOM element. Append your content to it.\n- `owner` The host element of the renderer function.\n- `model` The object with the properties related with rendering."
|
|
238
|
-
"attribute": "renderer"
|
|
226
|
+
"description": "Custom function for rendering the content of the overlay.\nReceives three arguments:\n\n- `root` The root container DOM element. Append your content to it.\n- `owner` The host element of the renderer function.\n- `model` The object with the properties related with rendering."
|
|
239
227
|
},
|
|
240
228
|
{
|
|
241
229
|
"kind": "method",
|
|
@@ -250,7 +238,6 @@
|
|
|
250
238
|
"text": "HTMLElement"
|
|
251
239
|
},
|
|
252
240
|
"description": "Set to specify the element which should be focused on overlay close,\nif `restoreFocusOnClose` is set to true.",
|
|
253
|
-
"attribute": "restore-focus-node",
|
|
254
241
|
"inheritedFrom": {
|
|
255
242
|
"name": "OverlayFocusMixin",
|
|
256
243
|
"module": "src/vaadin-overlay-focus-mixin.js"
|
|
@@ -321,7 +308,7 @@
|
|
|
321
308
|
"type": {
|
|
322
309
|
"text": "boolean"
|
|
323
310
|
},
|
|
324
|
-
"description": "Set to true to move focus into the overlay automatically on open.\n\nFocus moves to the first tabbable element in the tab order. This\ncan be the overlay itself if it has `tabindex` attribute set to `0`\non the host element or the `overlay` shadow DOM part.",
|
|
311
|
+
"description": "Set to true to move focus into the overlay automatically on open.\n\nFocus moves to the first tabbable element in the tab order. This\ncan be the overlay itself if it has `tabindex` attribute set to `0`\non the host element or the `overlay` shadow DOM part.\n\nAn element inside the overlay that has `autofocus` set, such as\n`<vaadin-text-field autofocus>`, receives focus on open instead,\neven when this property is false.",
|
|
325
312
|
"fieldName": "autofocus",
|
|
326
313
|
"inheritedFrom": {
|
|
327
314
|
"name": "OverlayFocusMixin",
|
|
@@ -364,34 +351,6 @@
|
|
|
364
351
|
"description": "When true, the overlay is visible and attached to body.",
|
|
365
352
|
"fieldName": "opened"
|
|
366
353
|
},
|
|
367
|
-
{
|
|
368
|
-
"name": "owner",
|
|
369
|
-
"type": {
|
|
370
|
-
"text": "HTMLElement"
|
|
371
|
-
},
|
|
372
|
-
"description": "Owner element passed with renderer function",
|
|
373
|
-
"fieldName": "owner"
|
|
374
|
-
},
|
|
375
|
-
{
|
|
376
|
-
"name": "renderer",
|
|
377
|
-
"type": {
|
|
378
|
-
"text": "OverlayRenderer | null | undefined"
|
|
379
|
-
},
|
|
380
|
-
"description": "Custom function for rendering the content of the overlay.\nReceives three arguments:\n\n- `root` The root container DOM element. Append your content to it.\n- `owner` The host element of the renderer function.\n- `model` The object with the properties related with rendering.",
|
|
381
|
-
"fieldName": "renderer"
|
|
382
|
-
},
|
|
383
|
-
{
|
|
384
|
-
"name": "restore-focus-node",
|
|
385
|
-
"type": {
|
|
386
|
-
"text": "HTMLElement"
|
|
387
|
-
},
|
|
388
|
-
"description": "Set to specify the element which should be focused on overlay close,\nif `restoreFocusOnClose` is set to true.",
|
|
389
|
-
"fieldName": "restoreFocusNode",
|
|
390
|
-
"inheritedFrom": {
|
|
391
|
-
"name": "OverlayFocusMixin",
|
|
392
|
-
"module": "src/vaadin-overlay-focus-mixin.js"
|
|
393
|
-
}
|
|
394
|
-
},
|
|
395
354
|
{
|
|
396
355
|
"name": "restore-focus-on-close",
|
|
397
356
|
"type": {
|
|
@@ -487,8 +446,7 @@
|
|
|
487
446
|
"type": {
|
|
488
447
|
"text": "object"
|
|
489
448
|
},
|
|
490
|
-
"description": "The element next to which this overlay should be aligned.\nThe position of the overlay relative to the positionTarget can be adjusted\nwith properties `horizontalAlign`, `verticalAlign`, `noHorizontalOverlap`\nand `noVerticalOverlap`."
|
|
491
|
-
"attribute": "position-target"
|
|
449
|
+
"description": "The element next to which this overlay should be aligned.\nThe position of the overlay relative to the positionTarget can be adjusted\nwith properties `horizontalAlign`, `verticalAlign`, `noHorizontalOverlap`\nand `noVerticalOverlap`."
|
|
492
450
|
},
|
|
493
451
|
{
|
|
494
452
|
"kind": "field",
|
|
@@ -727,7 +685,7 @@
|
|
|
727
685
|
"type": {
|
|
728
686
|
"text": "boolean"
|
|
729
687
|
},
|
|
730
|
-
"description": "Set to true to move focus into the overlay automatically on open.\n\nFocus moves to the first tabbable element in the tab order. This\ncan be the overlay itself if it has `tabindex` attribute set to `0`\non the host element or the `overlay` shadow DOM part.",
|
|
688
|
+
"description": "Set to true to move focus into the overlay automatically on open.\n\nFocus moves to the first tabbable element in the tab order. This\ncan be the overlay itself if it has `tabindex` attribute set to `0`\non the host element or the `overlay` shadow DOM part.\n\nAn element inside the overlay that has `autofocus` set, such as\n`<vaadin-text-field autofocus>`, receives focus on open instead,\neven when this property is false.",
|
|
731
689
|
"attribute": "autofocus",
|
|
732
690
|
"inheritedFrom": {
|
|
733
691
|
"name": "OverlayFocusMixin",
|
|
@@ -795,7 +753,6 @@
|
|
|
795
753
|
"text": "object"
|
|
796
754
|
},
|
|
797
755
|
"description": "Object with properties that is passed to `renderer` function",
|
|
798
|
-
"attribute": "model",
|
|
799
756
|
"inheritedFrom": {
|
|
800
757
|
"name": "OverlayMixin",
|
|
801
758
|
"module": "src/vaadin-overlay-mixin.js"
|
|
@@ -837,7 +794,6 @@
|
|
|
837
794
|
"text": "HTMLElement"
|
|
838
795
|
},
|
|
839
796
|
"description": "Owner element passed with renderer function",
|
|
840
|
-
"attribute": "owner",
|
|
841
797
|
"inheritedFrom": {
|
|
842
798
|
"name": "OverlayMixin",
|
|
843
799
|
"module": "src/vaadin-overlay-mixin.js"
|
|
@@ -851,7 +807,6 @@
|
|
|
851
807
|
"text": "OverlayRenderer | null | undefined"
|
|
852
808
|
},
|
|
853
809
|
"description": "Custom function for rendering the content of the overlay.\nReceives three arguments:\n\n- `root` The root container DOM element. Append your content to it.\n- `owner` The host element of the renderer function.\n- `model` The object with the properties related with rendering.",
|
|
854
|
-
"attribute": "renderer",
|
|
855
810
|
"inheritedFrom": {
|
|
856
811
|
"name": "OverlayMixin",
|
|
857
812
|
"module": "src/vaadin-overlay-mixin.js"
|
|
@@ -874,7 +829,6 @@
|
|
|
874
829
|
"text": "HTMLElement"
|
|
875
830
|
},
|
|
876
831
|
"description": "Set to specify the element which should be focused on overlay close,\nif `restoreFocusOnClose` is set to true.",
|
|
877
|
-
"attribute": "restore-focus-node",
|
|
878
832
|
"inheritedFrom": {
|
|
879
833
|
"name": "OverlayFocusMixin",
|
|
880
834
|
"module": "src/vaadin-overlay-focus-mixin.js"
|
|
@@ -949,26 +903,18 @@
|
|
|
949
903
|
"name": "vaadin-overlay-close"
|
|
950
904
|
},
|
|
951
905
|
{
|
|
952
|
-
"name": "vaadin-overlay-closed",
|
|
953
906
|
"type": {
|
|
954
907
|
"text": "CustomEvent"
|
|
955
908
|
},
|
|
956
909
|
"description": "Fired after the overlay is closed.",
|
|
957
|
-
"
|
|
958
|
-
"name": "OverlayMixin",
|
|
959
|
-
"module": "src/vaadin-overlay-mixin.js"
|
|
960
|
-
}
|
|
910
|
+
"name": "vaadin-overlay-closed"
|
|
961
911
|
},
|
|
962
912
|
{
|
|
963
|
-
"name": "vaadin-overlay-closing",
|
|
964
913
|
"type": {
|
|
965
914
|
"text": "CustomEvent"
|
|
966
915
|
},
|
|
967
916
|
"description": "Fired when the overlay starts to close. Closing the overlay can be asynchronous depending on the animation.",
|
|
968
|
-
"
|
|
969
|
-
"name": "OverlayMixin",
|
|
970
|
-
"module": "src/vaadin-overlay-mixin.js"
|
|
971
|
-
}
|
|
917
|
+
"name": "vaadin-overlay-closing"
|
|
972
918
|
},
|
|
973
919
|
{
|
|
974
920
|
"type": {
|
|
@@ -1027,7 +973,7 @@
|
|
|
1027
973
|
"type": {
|
|
1028
974
|
"text": "boolean"
|
|
1029
975
|
},
|
|
1030
|
-
"description": "Set to true to move focus into the overlay automatically on open.\n\nFocus moves to the first tabbable element in the tab order. This\ncan be the overlay itself if it has `tabindex` attribute set to `0`\non the host element or the `overlay` shadow DOM part.",
|
|
976
|
+
"description": "Set to true to move focus into the overlay automatically on open.\n\nFocus moves to the first tabbable element in the tab order. This\ncan be the overlay itself if it has `tabindex` attribute set to `0`\non the host element or the `overlay` shadow DOM part.\n\nAn element inside the overlay that has `autofocus` set, such as\n`<vaadin-text-field autofocus>`, receives focus on open instead,\neven when this property is false.",
|
|
1031
977
|
"fieldName": "autofocus",
|
|
1032
978
|
"inheritedFrom": {
|
|
1033
979
|
"name": "OverlayFocusMixin",
|
|
@@ -1082,42 +1028,6 @@
|
|
|
1082
1028
|
"module": "src/vaadin-overlay-mixin.js"
|
|
1083
1029
|
}
|
|
1084
1030
|
},
|
|
1085
|
-
{
|
|
1086
|
-
"name": "owner",
|
|
1087
|
-
"type": {
|
|
1088
|
-
"text": "HTMLElement"
|
|
1089
|
-
},
|
|
1090
|
-
"description": "Owner element passed with renderer function",
|
|
1091
|
-
"fieldName": "owner",
|
|
1092
|
-
"inheritedFrom": {
|
|
1093
|
-
"name": "OverlayMixin",
|
|
1094
|
-
"module": "src/vaadin-overlay-mixin.js"
|
|
1095
|
-
}
|
|
1096
|
-
},
|
|
1097
|
-
{
|
|
1098
|
-
"name": "renderer",
|
|
1099
|
-
"type": {
|
|
1100
|
-
"text": "OverlayRenderer | null | undefined"
|
|
1101
|
-
},
|
|
1102
|
-
"description": "Custom function for rendering the content of the overlay.\nReceives three arguments:\n\n- `root` The root container DOM element. Append your content to it.\n- `owner` The host element of the renderer function.\n- `model` The object with the properties related with rendering.",
|
|
1103
|
-
"fieldName": "renderer",
|
|
1104
|
-
"inheritedFrom": {
|
|
1105
|
-
"name": "OverlayMixin",
|
|
1106
|
-
"module": "src/vaadin-overlay-mixin.js"
|
|
1107
|
-
}
|
|
1108
|
-
},
|
|
1109
|
-
{
|
|
1110
|
-
"name": "restore-focus-node",
|
|
1111
|
-
"type": {
|
|
1112
|
-
"text": "HTMLElement"
|
|
1113
|
-
},
|
|
1114
|
-
"description": "Set to specify the element which should be focused on overlay close,\nif `restoreFocusOnClose` is set to true.",
|
|
1115
|
-
"fieldName": "restoreFocusNode",
|
|
1116
|
-
"inheritedFrom": {
|
|
1117
|
-
"name": "OverlayFocusMixin",
|
|
1118
|
-
"module": "src/vaadin-overlay-focus-mixin.js"
|
|
1119
|
-
}
|
|
1120
|
-
},
|
|
1121
1031
|
{
|
|
1122
1032
|
"name": "restore-focus-on-close",
|
|
1123
1033
|
"type": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/overlay",
|
|
3
|
-
"version": "25.4.0-
|
|
3
|
+
"version": "25.4.0-rc1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -34,19 +34,19 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
37
|
-
"@vaadin/a11y-base": "25.4.0-
|
|
38
|
-
"@vaadin/component-base": "25.4.0-
|
|
39
|
-
"@vaadin/vaadin-themable-mixin": "25.4.0-
|
|
37
|
+
"@vaadin/a11y-base": "25.4.0-rc1",
|
|
38
|
+
"@vaadin/component-base": "25.4.0-rc1",
|
|
39
|
+
"@vaadin/vaadin-themable-mixin": "25.4.0-rc1",
|
|
40
40
|
"lit": "^3.0.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@vaadin/aura": "25.4.0-
|
|
44
|
-
"@vaadin/chai-plugins": "25.4.0-
|
|
45
|
-
"@vaadin/test-runner-commands": "25.4.0-
|
|
43
|
+
"@vaadin/aura": "25.4.0-rc1",
|
|
44
|
+
"@vaadin/chai-plugins": "25.4.0-rc1",
|
|
45
|
+
"@vaadin/test-runner-commands": "25.4.0-rc1",
|
|
46
46
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
47
|
-
"@vaadin/vaadin-lumo-styles": "25.4.0-
|
|
47
|
+
"@vaadin/vaadin-lumo-styles": "25.4.0-rc1",
|
|
48
48
|
"sinon": "^22.0.0"
|
|
49
49
|
},
|
|
50
50
|
"customElements": "custom-elements.json",
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "abe6d2338024cb71110c7df9bd5d97c0d110a135"
|
|
52
52
|
}
|
|
@@ -29,6 +29,10 @@ export declare class OverlayFocusMixinClass {
|
|
|
29
29
|
* Focus moves to the first tabbable element in the tab order. This
|
|
30
30
|
* can be the overlay itself if it has `tabindex` attribute set to `0`
|
|
31
31
|
* on the host element or the `overlay` shadow DOM part.
|
|
32
|
+
*
|
|
33
|
+
* An element inside the overlay that has `autofocus` set, such as
|
|
34
|
+
* `<vaadin-text-field autofocus>`, receives focus on open instead,
|
|
35
|
+
* even when this property is false.
|
|
32
36
|
*/
|
|
33
37
|
autofocus: boolean;
|
|
34
38
|
|
|
@@ -73,7 +77,8 @@ export declare class OverlayFocusMixinClass {
|
|
|
73
77
|
|
|
74
78
|
/**
|
|
75
79
|
* Returns true if the overlay contains the given node,
|
|
76
|
-
* including those within shadow DOM trees
|
|
80
|
+
* including those within shadow DOM trees or slotted
|
|
81
|
+
* into the overlay from another tree.
|
|
77
82
|
*/
|
|
78
83
|
protected _deepContains(node: Node): boolean;
|
|
79
84
|
}
|
|
@@ -39,6 +39,10 @@ export const OverlayFocusMixin = (superClass) =>
|
|
|
39
39
|
* Focus moves to the first tabbable element in the tab order. This
|
|
40
40
|
* can be the overlay itself if it has `tabindex` attribute set to `0`
|
|
41
41
|
* on the host element or the `overlay` shadow DOM part.
|
|
42
|
+
*
|
|
43
|
+
* An element inside the overlay that has `autofocus` set, such as
|
|
44
|
+
* `<vaadin-text-field autofocus>`, receives focus on open instead,
|
|
45
|
+
* even when this property is false.
|
|
42
46
|
*/
|
|
43
47
|
autofocus: {
|
|
44
48
|
type: Boolean,
|
|
@@ -65,11 +69,25 @@ export const OverlayFocusMixin = (superClass) =>
|
|
|
65
69
|
};
|
|
66
70
|
}
|
|
67
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Whether the overlay moves, traps and restores focus. Override to return
|
|
74
|
+
* false in overlays that never do: focus properties are then ignored and
|
|
75
|
+
* the focus controllers are not created.
|
|
76
|
+
* @protected
|
|
77
|
+
*/
|
|
78
|
+
static get manageFocus() {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
|
|
68
82
|
constructor() {
|
|
69
83
|
super();
|
|
70
84
|
|
|
71
|
-
this.
|
|
72
|
-
|
|
85
|
+
this.__manageFocus = this.constructor.manageFocus;
|
|
86
|
+
|
|
87
|
+
if (this.__manageFocus) {
|
|
88
|
+
this.__focusTrapController = new FocusTrapController(this);
|
|
89
|
+
this.__focusRestorationController = new FocusRestorationController();
|
|
90
|
+
}
|
|
73
91
|
}
|
|
74
92
|
|
|
75
93
|
/**
|
|
@@ -85,8 +103,10 @@ export const OverlayFocusMixin = (superClass) =>
|
|
|
85
103
|
ready() {
|
|
86
104
|
super.ready();
|
|
87
105
|
|
|
88
|
-
|
|
89
|
-
|
|
106
|
+
if (this.__manageFocus) {
|
|
107
|
+
this.addController(this.__focusTrapController);
|
|
108
|
+
this.addController(this.__focusRestorationController);
|
|
109
|
+
}
|
|
90
110
|
}
|
|
91
111
|
|
|
92
112
|
/**
|
|
@@ -104,6 +124,10 @@ export const OverlayFocusMixin = (superClass) =>
|
|
|
104
124
|
* @protected
|
|
105
125
|
*/
|
|
106
126
|
_resetFocus() {
|
|
127
|
+
if (!this.__manageFocus) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
107
131
|
if (this.focusTrap) {
|
|
108
132
|
this.__focusTrapController.releaseFocus();
|
|
109
133
|
}
|
|
@@ -121,28 +145,32 @@ export const OverlayFocusMixin = (superClass) =>
|
|
|
121
145
|
* @protected
|
|
122
146
|
*/
|
|
123
147
|
_saveFocus() {
|
|
148
|
+
if (!this.__manageFocus) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
124
152
|
if (this.restoreFocusOnClose) {
|
|
125
153
|
this.__focusRestorationController.saveFocus(this.restoreFocusNode);
|
|
126
154
|
}
|
|
127
155
|
}
|
|
128
156
|
|
|
129
157
|
/**
|
|
130
|
-
* Sets up focus after the overlay opening has completed: moves focus
|
|
131
|
-
* the
|
|
132
|
-
* if `
|
|
158
|
+
* Sets up focus after the overlay opening has completed: moves focus to
|
|
159
|
+
* the first element with `autofocus` inside the overlay, otherwise to the
|
|
160
|
+
* first tabbable element if the `autofocus` property is set, and traps
|
|
161
|
+
* focus if `focusTrap` is set.
|
|
133
162
|
*
|
|
134
163
|
* @protected
|
|
135
164
|
*/
|
|
136
165
|
_initFocus() {
|
|
137
|
-
if (isElementHidden(this._focusRoot)) {
|
|
166
|
+
if (!this.__manageFocus || isElementHidden(this._focusRoot)) {
|
|
138
167
|
return;
|
|
139
168
|
}
|
|
140
169
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
170
|
+
const tabbables = getTabbableElements(this._focusRoot);
|
|
171
|
+
if (!tabbables.some(isElementFocused)) {
|
|
172
|
+
const target = tabbables.find((el) => this.#hasAutofocus(el)) ?? (this.autofocus ? tabbables[0] : null);
|
|
173
|
+
target?.focus({ focusVisible: isKeyboardActive() });
|
|
146
174
|
}
|
|
147
175
|
|
|
148
176
|
if (this.focusTrap) {
|
|
@@ -168,7 +196,8 @@ export const OverlayFocusMixin = (superClass) =>
|
|
|
168
196
|
|
|
169
197
|
/**
|
|
170
198
|
* Returns true if the overlay contains the given node,
|
|
171
|
-
* including those within shadow DOM trees
|
|
199
|
+
* including those within shadow DOM trees or slotted
|
|
200
|
+
* into the overlay from another tree.
|
|
172
201
|
*
|
|
173
202
|
* @param {Node} node
|
|
174
203
|
* @return {boolean}
|
|
@@ -180,10 +209,33 @@ export const OverlayFocusMixin = (superClass) =>
|
|
|
180
209
|
}
|
|
181
210
|
let n = node;
|
|
182
211
|
const doc = node.ownerDocument;
|
|
183
|
-
// Walk from node to content root or `document`
|
|
212
|
+
// Walk the composed tree from node to content root or `document`
|
|
184
213
|
while (n && n !== doc && n !== this._contentRoot) {
|
|
185
|
-
n = n.parentNode || n.host;
|
|
214
|
+
n = n.assignedSlot || n.parentNode || n.host;
|
|
186
215
|
}
|
|
187
216
|
return n === this._contentRoot;
|
|
188
217
|
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Returns true if the element has `autofocus`, or belongs to a custom
|
|
221
|
+
* element that has it (e.g. the input of `<vaadin-text-field autofocus>`).
|
|
222
|
+
* As with native `autofocus`, a plain `<div autofocus>` does not apply to
|
|
223
|
+
* its children. Stops at the focus root, whose `autofocus` refers to the overlay.
|
|
224
|
+
* Walks the flat tree, the same way tabbables are collected from the focus root,
|
|
225
|
+
* so it never leaves the overlay when content is slotted from the owner.
|
|
226
|
+
*
|
|
227
|
+
* @param {HTMLElement} element
|
|
228
|
+
* @return {boolean}
|
|
229
|
+
*/
|
|
230
|
+
#hasAutofocus(element) {
|
|
231
|
+
const focusRoot = this._focusRoot;
|
|
232
|
+
let node = element;
|
|
233
|
+
while (node && node !== focusRoot && node !== this) {
|
|
234
|
+
if (node.autofocus && (node === element || customElements.get(node.localName))) {
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
node = node.assignedSlot || node.parentNode || node.host;
|
|
238
|
+
}
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
189
241
|
};
|