@spectrum-web-components/menu 0.14.2 → 0.14.5-devmode.0
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 +11 -1
- package/package.json +55 -20
- package/sp-menu-divider.dev.js +3 -0
- package/sp-menu-divider.dev.js.map +7 -0
- package/sp-menu-divider.js +3 -14
- package/sp-menu-divider.js.map +7 -1
- package/sp-menu-group.dev.js +3 -0
- package/sp-menu-group.dev.js.map +7 -0
- package/sp-menu-group.js +3 -14
- package/sp-menu-group.js.map +7 -1
- package/sp-menu-item.dev.js +3 -0
- package/sp-menu-item.dev.js.map +7 -0
- package/sp-menu-item.js +3 -14
- package/sp-menu-item.js.map +7 -1
- package/sp-menu.dev.js +3 -0
- package/sp-menu.dev.js.map +7 -0
- package/sp-menu.js +3 -14
- package/sp-menu.js.map +7 -1
- package/src/Menu.dev.js +495 -0
- package/src/Menu.dev.js.map +7 -0
- package/src/Menu.js +487 -574
- package/src/Menu.js.map +7 -1
- package/src/MenuDivider.dev.js +13 -0
- package/src/MenuDivider.dev.js.map +7 -0
- package/src/MenuDivider.js +11 -25
- package/src/MenuDivider.js.map +7 -1
- package/src/MenuGroup.dev.js +82 -0
- package/src/MenuGroup.dev.js.map +7 -0
- package/src/MenuGroup.js +67 -71
- package/src/MenuGroup.js.map +7 -1
- package/src/MenuItem.d.ts +2 -1
- package/src/MenuItem.dev.js +424 -0
- package/src/MenuItem.dev.js.map +7 -0
- package/src/MenuItem.js +399 -415
- package/src/MenuItem.js.map +7 -1
- package/src/index.dev.js +5 -0
- package/src/index.dev.js.map +7 -0
- package/src/index.js +5 -16
- package/src/index.js.map +7 -1
- package/src/menu-divider.css.dev.js +6 -0
- package/src/menu-divider.css.dev.js.map +7 -0
- package/src/menu-divider.css.js +3 -14
- package/src/menu-divider.css.js.map +7 -1
- package/src/menu-group.css.dev.js +8 -0
- package/src/menu-group.css.dev.js.map +7 -0
- package/src/menu-group.css.js +3 -14
- package/src/menu-group.css.js.map +7 -1
- package/src/menu-item.css.dev.js +73 -0
- package/src/menu-item.css.dev.js.map +7 -0
- package/src/menu-item.css.js +3 -14
- package/src/menu-item.css.js.map +7 -1
- package/src/menu.css.dev.js +61 -0
- package/src/menu.css.dev.js.map +7 -0
- package/src/menu.css.js +3 -14
- package/src/menu.css.js.map +7 -1
- package/src/spectrum-checkmark.css.dev.js +10 -0
- package/src/spectrum-checkmark.css.dev.js.map +7 -0
- package/src/spectrum-checkmark.css.js +3 -14
- package/src/spectrum-checkmark.css.js.map +7 -1
- package/src/spectrum-chevron.css.dev.js +10 -0
- package/src/spectrum-chevron.css.dev.js.map +7 -0
- package/src/spectrum-chevron.css.js +3 -14
- package/src/spectrum-chevron.css.js.map +7 -1
- package/src/spectrum-itemLabel.css.dev.js +6 -0
- package/src/spectrum-itemLabel.css.dev.js.map +7 -0
- package/src/spectrum-itemLabel.css.js +3 -14
- package/src/spectrum-itemLabel.css.js.map +7 -1
- package/src/spectrum-menu-divider.css.dev.js +6 -0
- package/src/spectrum-menu-divider.css.dev.js.map +7 -0
- package/src/spectrum-menu-divider.css.js +3 -14
- package/src/spectrum-menu-divider.css.js.map +7 -1
- package/src/spectrum-menu-item.css.dev.js +65 -0
- package/src/spectrum-menu-item.css.dev.js.map +7 -0
- package/src/spectrum-menu-item.css.js +3 -14
- package/src/spectrum-menu-item.css.js.map +7 -1
- package/src/spectrum-menu-sectionHeading.css.dev.js +8 -0
- package/src/spectrum-menu-sectionHeading.css.dev.js.map +7 -0
- package/src/spectrum-menu-sectionHeading.css.js +3 -14
- package/src/spectrum-menu-sectionHeading.css.js.map +7 -1
- package/src/spectrum-menu.css.dev.js +61 -0
- package/src/spectrum-menu.css.dev.js.map +7 -0
- package/src/spectrum-menu.css.js +3 -14
- package/src/spectrum-menu.css.js.map +7 -1
- package/stories/menu-group.stories.js +51 -58
- package/stories/menu-group.stories.js.map +7 -1
- package/stories/menu-item.stories.js +12 -32
- package/stories/menu-item.stories.js.map +7 -1
- package/stories/menu.stories.js +22 -33
- package/stories/menu.stories.js.map +7 -1
- package/stories/submenu.stories.js +125 -136
- package/stories/submenu.stories.js.map +7 -1
- package/test/benchmark/test-basic.js +8 -19
- package/test/benchmark/test-basic.js.map +7 -1
- package/test/menu-group.test-vrt.js +4 -15
- package/test/menu-group.test-vrt.js.map +7 -1
- package/test/menu-group.test.js +161 -168
- package/test/menu-group.test.js.map +7 -1
- package/test/menu-item.test-vrt.js +4 -15
- package/test/menu-item.test-vrt.js.map +7 -1
- package/test/menu-item.test.js +93 -99
- package/test/menu-item.test.js.map +7 -1
- package/test/menu-selects.test.js +488 -494
- package/test/menu-selects.test.js.map +7 -1
- package/test/menu.test-vrt.js +4 -15
- package/test/menu.test-vrt.js.map +7 -1
- package/test/menu.test.js +240 -257
- package/test/menu.test.js.map +7 -1
- package/test/submenu.test-vrt.js +4 -15
- package/test/submenu.test-vrt.js.map +7 -1
- package/test/submenu.test.js +480 -464
- package/test/submenu.test.js.map +7 -1
package/test/submenu.test.js
CHANGED
|
@@ -1,49 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
import '@spectrum-web-components/menu/sp-menu-group.js';
|
|
22
|
-
import '@spectrum-web-components/icons-workflow/icons/sp-icon-show-menu.js';
|
|
23
|
-
async function styledFixture(story, dir = 'ltr') {
|
|
24
|
-
const test = await fixture(html `
|
|
1
|
+
import "@spectrum-web-components/menu/sp-menu.js";
|
|
2
|
+
import "@spectrum-web-components/menu/sp-menu-item.js";
|
|
3
|
+
import {
|
|
4
|
+
elementUpdated,
|
|
5
|
+
expect,
|
|
6
|
+
fixture,
|
|
7
|
+
html,
|
|
8
|
+
nextFrame,
|
|
9
|
+
oneEvent
|
|
10
|
+
} from "@open-wc/testing";
|
|
11
|
+
import "@spectrum-web-components/theme/sp-theme.js";
|
|
12
|
+
import "@spectrum-web-components/theme/src/themes.js";
|
|
13
|
+
import { sendMouse } from "../../../test/plugins/browser.js";
|
|
14
|
+
import { spy } from "sinon";
|
|
15
|
+
import { sendKeys } from "@web/test-runner-commands";
|
|
16
|
+
import "@spectrum-web-components/action-menu/sp-action-menu.js";
|
|
17
|
+
import "@spectrum-web-components/menu/sp-menu-group.js";
|
|
18
|
+
import "@spectrum-web-components/icons-workflow/icons/sp-icon-show-menu.js";
|
|
19
|
+
async function styledFixture(story, dir = "ltr") {
|
|
20
|
+
const test = await fixture(html`
|
|
25
21
|
<sp-theme dir=${dir} scale="medium" color="dark">${story}</sp-theme>
|
|
26
22
|
`);
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
document.documentElement.dir = dir;
|
|
24
|
+
return test.children[0];
|
|
29
25
|
}
|
|
30
|
-
describe(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
describe("Submenu", () => {
|
|
27
|
+
it("selects - pointer", async () => {
|
|
28
|
+
const rootChanged = spy();
|
|
29
|
+
const submenuChanged = spy();
|
|
30
|
+
const el = await styledFixture(html`
|
|
35
31
|
<sp-menu
|
|
36
32
|
@change=${(event) => {
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
rootChanged(event.target.value);
|
|
34
|
+
}}
|
|
39
35
|
>
|
|
40
36
|
<sp-menu-item class="root">
|
|
41
37
|
Has submenu
|
|
42
38
|
<sp-menu
|
|
43
39
|
slot="submenu"
|
|
44
40
|
@change=${(event) => {
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
submenuChanged(event.target.value);
|
|
42
|
+
}}
|
|
47
43
|
>
|
|
48
44
|
<sp-menu-item class="submenu-item-1">
|
|
49
45
|
One
|
|
@@ -58,63 +54,60 @@ describe('Submenu', () => {
|
|
|
58
54
|
</sp-menu-item>
|
|
59
55
|
</sp-menu>
|
|
60
56
|
`);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
},
|
|
93
|
-
],
|
|
94
|
-
});
|
|
95
|
-
await closed;
|
|
96
|
-
await nextFrame();
|
|
97
|
-
expect(rootChanged.calledWith('Has submenu'), 'root changed').to.be
|
|
98
|
-
.true;
|
|
99
|
-
expect(submenuChanged.calledWith('Two'), 'submenu changed').to.be.true;
|
|
57
|
+
await elementUpdated(el);
|
|
58
|
+
const rootItem = el.querySelector(".root");
|
|
59
|
+
const rootItemBoundingRect = rootItem.getBoundingClientRect();
|
|
60
|
+
expect(rootItem.open).to.be.false;
|
|
61
|
+
const opened = oneEvent(rootItem, "sp-opened");
|
|
62
|
+
sendMouse({
|
|
63
|
+
steps: [
|
|
64
|
+
{
|
|
65
|
+
type: "move",
|
|
66
|
+
position: [
|
|
67
|
+
rootItemBoundingRect.left + rootItemBoundingRect.width / 2,
|
|
68
|
+
rootItemBoundingRect.top + rootItemBoundingRect.height / 2
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
});
|
|
73
|
+
await opened;
|
|
74
|
+
expect(rootItem.open).to.be.true;
|
|
75
|
+
const item2 = document.querySelector(".submenu-item-2");
|
|
76
|
+
const item2BoundingRect = item2.getBoundingClientRect();
|
|
77
|
+
const closed = oneEvent(rootItem, "sp-closed");
|
|
78
|
+
sendMouse({
|
|
79
|
+
steps: [
|
|
80
|
+
{
|
|
81
|
+
type: "click",
|
|
82
|
+
position: [
|
|
83
|
+
item2BoundingRect.left + item2BoundingRect.width / 2,
|
|
84
|
+
item2BoundingRect.top + item2BoundingRect.height / 2
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
]
|
|
100
88
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
89
|
+
await closed;
|
|
90
|
+
await nextFrame();
|
|
91
|
+
expect(rootChanged.calledWith("Has submenu"), "root changed").to.be.true;
|
|
92
|
+
expect(submenuChanged.calledWith("Two"), "submenu changed").to.be.true;
|
|
93
|
+
});
|
|
94
|
+
it("closes deep tree on selection", async () => {
|
|
95
|
+
const rootChanged = spy();
|
|
96
|
+
const submenuChanged = spy();
|
|
97
|
+
const subSubmenuChanged = spy();
|
|
98
|
+
const el = await styledFixture(html`
|
|
106
99
|
<sp-menu
|
|
107
100
|
@change=${(event) => {
|
|
108
|
-
|
|
109
|
-
|
|
101
|
+
rootChanged(event.target.value);
|
|
102
|
+
}}
|
|
110
103
|
>
|
|
111
104
|
<sp-menu-item class="root">
|
|
112
105
|
Has submenu
|
|
113
106
|
<sp-menu
|
|
114
107
|
slot="submenu"
|
|
115
108
|
@change=${(event) => {
|
|
116
|
-
|
|
117
|
-
|
|
109
|
+
submenuChanged(event.target.value);
|
|
110
|
+
}}
|
|
118
111
|
>
|
|
119
112
|
<sp-menu-item class="submenu-item-1">
|
|
120
113
|
One
|
|
@@ -124,8 +117,8 @@ describe('Submenu', () => {
|
|
|
124
117
|
<sp-menu
|
|
125
118
|
slot="submenu"
|
|
126
119
|
@change=${(event) => {
|
|
127
|
-
|
|
128
|
-
|
|
120
|
+
subSubmenuChanged(event.target.value);
|
|
121
|
+
}}
|
|
129
122
|
>
|
|
130
123
|
<sp-menu-item class="sub-submenu-item-1">
|
|
131
124
|
A
|
|
@@ -145,93 +138,89 @@ describe('Submenu', () => {
|
|
|
145
138
|
</sp-menu-item>
|
|
146
139
|
</sp-menu>
|
|
147
140
|
`);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
},
|
|
164
|
-
],
|
|
165
|
-
});
|
|
166
|
-
await opened;
|
|
167
|
-
expect(rootItem.open).to.be.true;
|
|
168
|
-
const item2 = document.querySelector('.submenu-item-2');
|
|
169
|
-
const item2BoundingRect = item2.getBoundingClientRect();
|
|
170
|
-
let closed = oneEvent(item2, 'sp-opened');
|
|
171
|
-
sendMouse({
|
|
172
|
-
steps: [
|
|
173
|
-
{
|
|
174
|
-
type: 'click',
|
|
175
|
-
position: [
|
|
176
|
-
item2BoundingRect.left + item2BoundingRect.width / 2,
|
|
177
|
-
item2BoundingRect.top + item2BoundingRect.height / 2,
|
|
178
|
-
],
|
|
179
|
-
},
|
|
180
|
-
],
|
|
181
|
-
});
|
|
182
|
-
await closed;
|
|
183
|
-
await nextFrame();
|
|
184
|
-
expect(item2.open).to.be.true;
|
|
185
|
-
const itemC = document.querySelector('.sub-submenu-item-3');
|
|
186
|
-
const itemCBoundingRect = itemC.getBoundingClientRect();
|
|
187
|
-
closed = oneEvent(rootItem, 'sp-closed');
|
|
188
|
-
sendMouse({
|
|
189
|
-
steps: [
|
|
190
|
-
{
|
|
191
|
-
type: 'click',
|
|
192
|
-
position: [
|
|
193
|
-
itemCBoundingRect.left + itemCBoundingRect.width / 2,
|
|
194
|
-
itemCBoundingRect.top + itemCBoundingRect.height / 2,
|
|
195
|
-
],
|
|
196
|
-
},
|
|
197
|
-
],
|
|
198
|
-
});
|
|
199
|
-
await closed;
|
|
200
|
-
await nextFrame();
|
|
201
|
-
expect(rootChanged.calledWith('Has submenu'), 'root changed').to.be
|
|
202
|
-
.true;
|
|
203
|
-
expect(submenuChanged.calledWith('Two'), 'submenu changed').to.be.true;
|
|
204
|
-
expect(subSubmenuChanged.calledWith('C'), 'sub submenu changed').to.be
|
|
205
|
-
.true;
|
|
141
|
+
await elementUpdated(el);
|
|
142
|
+
const rootItem = el.querySelector(".root");
|
|
143
|
+
const rootItemBoundingRect = rootItem.getBoundingClientRect();
|
|
144
|
+
expect(rootItem.open).to.be.false;
|
|
145
|
+
const opened = oneEvent(rootItem, "sp-opened");
|
|
146
|
+
sendMouse({
|
|
147
|
+
steps: [
|
|
148
|
+
{
|
|
149
|
+
type: "move",
|
|
150
|
+
position: [
|
|
151
|
+
rootItemBoundingRect.left + rootItemBoundingRect.width / 2,
|
|
152
|
+
rootItemBoundingRect.top + rootItemBoundingRect.height / 2
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
]
|
|
206
156
|
});
|
|
207
|
-
|
|
157
|
+
await opened;
|
|
158
|
+
expect(rootItem.open).to.be.true;
|
|
159
|
+
const item2 = document.querySelector(".submenu-item-2");
|
|
160
|
+
const item2BoundingRect = item2.getBoundingClientRect();
|
|
161
|
+
let closed = oneEvent(item2, "sp-opened");
|
|
162
|
+
sendMouse({
|
|
163
|
+
steps: [
|
|
208
164
|
{
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
165
|
+
type: "click",
|
|
166
|
+
position: [
|
|
167
|
+
item2BoundingRect.left + item2BoundingRect.width / 2,
|
|
168
|
+
item2BoundingRect.top + item2BoundingRect.height / 2
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
]
|
|
172
|
+
});
|
|
173
|
+
await closed;
|
|
174
|
+
await nextFrame();
|
|
175
|
+
expect(item2.open).to.be.true;
|
|
176
|
+
const itemC = document.querySelector(".sub-submenu-item-3");
|
|
177
|
+
const itemCBoundingRect = itemC.getBoundingClientRect();
|
|
178
|
+
closed = oneEvent(rootItem, "sp-closed");
|
|
179
|
+
sendMouse({
|
|
180
|
+
steps: [
|
|
213
181
|
{
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
182
|
+
type: "click",
|
|
183
|
+
position: [
|
|
184
|
+
itemCBoundingRect.left + itemCBoundingRect.width / 2,
|
|
185
|
+
itemCBoundingRect.top + itemCBoundingRect.height / 2
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
]
|
|
189
|
+
});
|
|
190
|
+
await closed;
|
|
191
|
+
await nextFrame();
|
|
192
|
+
expect(rootChanged.calledWith("Has submenu"), "root changed").to.be.true;
|
|
193
|
+
expect(submenuChanged.calledWith("Two"), "submenu changed").to.be.true;
|
|
194
|
+
expect(subSubmenuChanged.calledWith("C"), "sub submenu changed").to.be.true;
|
|
195
|
+
});
|
|
196
|
+
[
|
|
197
|
+
{
|
|
198
|
+
dir: "ltr",
|
|
199
|
+
openKey: "ArrowRight",
|
|
200
|
+
closeKey: "ArrowLeft"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
dir: "rtl",
|
|
204
|
+
openKey: "ArrowLeft",
|
|
205
|
+
closeKey: "ArrowRight"
|
|
206
|
+
}
|
|
207
|
+
].map((testData) => {
|
|
208
|
+
it(`selects - keyboard: ${testData.dir}`, async () => {
|
|
209
|
+
const rootChanged = spy();
|
|
210
|
+
const submenuChanged = spy();
|
|
211
|
+
const el = await styledFixture(html`
|
|
223
212
|
<sp-menu
|
|
224
213
|
@change=${(event) => {
|
|
225
|
-
|
|
226
|
-
|
|
214
|
+
rootChanged(event.target.value);
|
|
215
|
+
}}
|
|
227
216
|
>
|
|
228
217
|
<sp-menu-item class="root">
|
|
229
218
|
Has submenu
|
|
230
219
|
<sp-menu
|
|
231
220
|
slot="submenu"
|
|
232
221
|
@change=${(event) => {
|
|
233
|
-
|
|
234
|
-
|
|
222
|
+
submenuChanged(event.target.value);
|
|
223
|
+
}}
|
|
235
224
|
>
|
|
236
225
|
<sp-menu-item class="submenu-item-1">
|
|
237
226
|
One
|
|
@@ -246,45 +235,43 @@ describe('Submenu', () => {
|
|
|
246
235
|
</sp-menu-item>
|
|
247
236
|
</sp-menu>
|
|
248
237
|
`, testData.dir);
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
expect(submenuChanged.calledWith('Two'), 'submenu changed').to.be
|
|
283
|
-
.true;
|
|
284
|
-
});
|
|
238
|
+
await elementUpdated(el);
|
|
239
|
+
const rootItem = el.querySelector(".root");
|
|
240
|
+
expect(rootItem.open).to.be.false;
|
|
241
|
+
el.focus();
|
|
242
|
+
await elementUpdated(el);
|
|
243
|
+
let opened = oneEvent(rootItem, "sp-opened");
|
|
244
|
+
sendKeys({
|
|
245
|
+
press: testData.openKey
|
|
246
|
+
});
|
|
247
|
+
await opened;
|
|
248
|
+
expect(rootItem.open).to.be.true;
|
|
249
|
+
let closed = oneEvent(rootItem, "sp-closed");
|
|
250
|
+
sendKeys({
|
|
251
|
+
press: testData.closeKey
|
|
252
|
+
});
|
|
253
|
+
await closed;
|
|
254
|
+
expect(rootItem.open).to.be.false;
|
|
255
|
+
opened = oneEvent(rootItem, "sp-opened");
|
|
256
|
+
sendKeys({
|
|
257
|
+
press: testData.openKey
|
|
258
|
+
});
|
|
259
|
+
await opened;
|
|
260
|
+
expect(rootItem.open).to.be.true;
|
|
261
|
+
await sendKeys({
|
|
262
|
+
press: "ArrowDown"
|
|
263
|
+
});
|
|
264
|
+
closed = oneEvent(rootItem, "sp-closed");
|
|
265
|
+
sendKeys({
|
|
266
|
+
press: "Enter"
|
|
267
|
+
});
|
|
268
|
+
await closed;
|
|
269
|
+
expect(rootChanged.calledWith("Has submenu"), "root changed").to.be.true;
|
|
270
|
+
expect(submenuChanged.calledWith("Two"), "submenu changed").to.be.true;
|
|
285
271
|
});
|
|
286
|
-
|
|
287
|
-
|
|
272
|
+
});
|
|
273
|
+
it("closes on `pointerleave`", async () => {
|
|
274
|
+
const el = await styledFixture(html`
|
|
288
275
|
<sp-menu>
|
|
289
276
|
<sp-menu-item class="root">
|
|
290
277
|
Has submenu
|
|
@@ -302,45 +289,41 @@ describe('Submenu', () => {
|
|
|
302
289
|
</sp-menu-item>
|
|
303
290
|
</sp-menu>
|
|
304
291
|
`);
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
},
|
|
321
|
-
],
|
|
322
|
-
});
|
|
323
|
-
await opened;
|
|
324
|
-
expect(rootItem.open).to.be.true;
|
|
325
|
-
const closed = oneEvent(rootItem, 'sp-closed');
|
|
326
|
-
sendMouse({
|
|
327
|
-
steps: [
|
|
328
|
-
{
|
|
329
|
-
type: 'move',
|
|
330
|
-
position: [
|
|
331
|
-
rootItemBoundingRect.left +
|
|
332
|
-
rootItemBoundingRect.width / 2,
|
|
333
|
-
rootItemBoundingRect.top +
|
|
334
|
-
rootItemBoundingRect.height * 2,
|
|
335
|
-
],
|
|
336
|
-
},
|
|
337
|
-
],
|
|
338
|
-
});
|
|
339
|
-
await closed;
|
|
340
|
-
expect(rootItem.open).to.be.false;
|
|
292
|
+
await elementUpdated(el);
|
|
293
|
+
const rootItem = el.querySelector(".root");
|
|
294
|
+
const rootItemBoundingRect = rootItem.getBoundingClientRect();
|
|
295
|
+
expect(rootItem.open).to.be.false;
|
|
296
|
+
const opened = oneEvent(rootItem, "sp-opened");
|
|
297
|
+
sendMouse({
|
|
298
|
+
steps: [
|
|
299
|
+
{
|
|
300
|
+
type: "move",
|
|
301
|
+
position: [
|
|
302
|
+
rootItemBoundingRect.left + rootItemBoundingRect.width / 2,
|
|
303
|
+
rootItemBoundingRect.top + rootItemBoundingRect.height / 2
|
|
304
|
+
]
|
|
305
|
+
}
|
|
306
|
+
]
|
|
341
307
|
});
|
|
342
|
-
|
|
343
|
-
|
|
308
|
+
await opened;
|
|
309
|
+
expect(rootItem.open).to.be.true;
|
|
310
|
+
const closed = oneEvent(rootItem, "sp-closed");
|
|
311
|
+
sendMouse({
|
|
312
|
+
steps: [
|
|
313
|
+
{
|
|
314
|
+
type: "move",
|
|
315
|
+
position: [
|
|
316
|
+
rootItemBoundingRect.left + rootItemBoundingRect.width / 2,
|
|
317
|
+
rootItemBoundingRect.top + rootItemBoundingRect.height * 2
|
|
318
|
+
]
|
|
319
|
+
}
|
|
320
|
+
]
|
|
321
|
+
});
|
|
322
|
+
await closed;
|
|
323
|
+
expect(rootItem.open).to.be.false;
|
|
324
|
+
});
|
|
325
|
+
it("stays open when mousing off menu item and back again", async () => {
|
|
326
|
+
const el = await styledFixture(html`
|
|
344
327
|
<sp-menu>
|
|
345
328
|
<sp-menu-item class="root">
|
|
346
329
|
Has submenu
|
|
@@ -358,70 +341,62 @@ describe('Submenu', () => {
|
|
|
358
341
|
</sp-menu-item>
|
|
359
342
|
</sp-menu>
|
|
360
343
|
`);
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
position: [
|
|
413
|
-
rootItemBoundingRect.left +
|
|
414
|
-
rootItemBoundingRect.width / 2,
|
|
415
|
-
rootItemBoundingRect.top +
|
|
416
|
-
rootItemBoundingRect.height * 2,
|
|
417
|
-
],
|
|
418
|
-
},
|
|
419
|
-
],
|
|
420
|
-
});
|
|
421
|
-
await closed;
|
|
344
|
+
await elementUpdated(el);
|
|
345
|
+
const rootItem = el.querySelector(".root");
|
|
346
|
+
const rootItemBoundingRect = rootItem.getBoundingClientRect();
|
|
347
|
+
expect(rootItem.open).to.be.false;
|
|
348
|
+
const opened = oneEvent(rootItem, "sp-opened");
|
|
349
|
+
await sendMouse({
|
|
350
|
+
steps: [
|
|
351
|
+
{
|
|
352
|
+
type: "move",
|
|
353
|
+
position: [
|
|
354
|
+
rootItemBoundingRect.left + rootItemBoundingRect.width / 2,
|
|
355
|
+
rootItemBoundingRect.top + rootItemBoundingRect.height / 2
|
|
356
|
+
]
|
|
357
|
+
}
|
|
358
|
+
]
|
|
359
|
+
});
|
|
360
|
+
await sendMouse({
|
|
361
|
+
steps: [
|
|
362
|
+
{
|
|
363
|
+
type: "move",
|
|
364
|
+
position: [
|
|
365
|
+
rootItemBoundingRect.left + rootItemBoundingRect.width / 2,
|
|
366
|
+
rootItemBoundingRect.top + rootItemBoundingRect.height * 2
|
|
367
|
+
]
|
|
368
|
+
}
|
|
369
|
+
]
|
|
370
|
+
});
|
|
371
|
+
await sendMouse({
|
|
372
|
+
steps: [
|
|
373
|
+
{
|
|
374
|
+
type: "move",
|
|
375
|
+
position: [
|
|
376
|
+
rootItemBoundingRect.left + rootItemBoundingRect.width / 2,
|
|
377
|
+
rootItemBoundingRect.top + rootItemBoundingRect.height / 2
|
|
378
|
+
]
|
|
379
|
+
}
|
|
380
|
+
]
|
|
381
|
+
});
|
|
382
|
+
await opened;
|
|
383
|
+
expect(rootItem.open).to.be.true;
|
|
384
|
+
const closed = oneEvent(rootItem, "sp-closed");
|
|
385
|
+
sendMouse({
|
|
386
|
+
steps: [
|
|
387
|
+
{
|
|
388
|
+
type: "move",
|
|
389
|
+
position: [
|
|
390
|
+
rootItemBoundingRect.left + rootItemBoundingRect.width / 2,
|
|
391
|
+
rootItemBoundingRect.top + rootItemBoundingRect.height * 2
|
|
392
|
+
]
|
|
393
|
+
}
|
|
394
|
+
]
|
|
422
395
|
});
|
|
423
|
-
|
|
424
|
-
|
|
396
|
+
await closed;
|
|
397
|
+
});
|
|
398
|
+
it("stays open when mousing between menu item and submenu", async () => {
|
|
399
|
+
const el = await styledFixture(html`
|
|
425
400
|
<sp-menu>
|
|
426
401
|
<sp-menu-item class="root">
|
|
427
402
|
Has submenu
|
|
@@ -439,55 +414,49 @@ describe('Submenu', () => {
|
|
|
439
414
|
</sp-menu-item>
|
|
440
415
|
</sp-menu>
|
|
441
416
|
`);
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
},
|
|
458
|
-
],
|
|
459
|
-
});
|
|
460
|
-
await sendMouse({
|
|
461
|
-
steps: [
|
|
462
|
-
{
|
|
463
|
-
type: 'move',
|
|
464
|
-
position: [
|
|
465
|
-
rootItemBoundingRect.left +
|
|
466
|
-
rootItemBoundingRect.width / 2,
|
|
467
|
-
rootItemBoundingRect.top +
|
|
468
|
-
rootItemBoundingRect.height * 2,
|
|
469
|
-
],
|
|
470
|
-
},
|
|
471
|
-
],
|
|
472
|
-
});
|
|
473
|
-
await sendMouse({
|
|
474
|
-
steps: [
|
|
475
|
-
{
|
|
476
|
-
type: 'move',
|
|
477
|
-
position: [
|
|
478
|
-
rootItemBoundingRect.left +
|
|
479
|
-
rootItemBoundingRect.width * 1.5,
|
|
480
|
-
rootItemBoundingRect.top +
|
|
481
|
-
rootItemBoundingRect.height / 2,
|
|
482
|
-
],
|
|
483
|
-
},
|
|
484
|
-
],
|
|
485
|
-
});
|
|
486
|
-
await opened;
|
|
487
|
-
expect(rootItem.open).to.be.true;
|
|
417
|
+
await elementUpdated(el);
|
|
418
|
+
const rootItem = el.querySelector(".root");
|
|
419
|
+
const rootItemBoundingRect = rootItem.getBoundingClientRect();
|
|
420
|
+
expect(rootItem.open).to.be.false;
|
|
421
|
+
const opened = oneEvent(rootItem, "sp-opened");
|
|
422
|
+
await sendMouse({
|
|
423
|
+
steps: [
|
|
424
|
+
{
|
|
425
|
+
type: "move",
|
|
426
|
+
position: [
|
|
427
|
+
rootItemBoundingRect.left + rootItemBoundingRect.width / 2,
|
|
428
|
+
rootItemBoundingRect.top + rootItemBoundingRect.height / 2
|
|
429
|
+
]
|
|
430
|
+
}
|
|
431
|
+
]
|
|
488
432
|
});
|
|
489
|
-
|
|
490
|
-
|
|
433
|
+
await sendMouse({
|
|
434
|
+
steps: [
|
|
435
|
+
{
|
|
436
|
+
type: "move",
|
|
437
|
+
position: [
|
|
438
|
+
rootItemBoundingRect.left + rootItemBoundingRect.width / 2,
|
|
439
|
+
rootItemBoundingRect.top + rootItemBoundingRect.height * 2
|
|
440
|
+
]
|
|
441
|
+
}
|
|
442
|
+
]
|
|
443
|
+
});
|
|
444
|
+
await sendMouse({
|
|
445
|
+
steps: [
|
|
446
|
+
{
|
|
447
|
+
type: "move",
|
|
448
|
+
position: [
|
|
449
|
+
rootItemBoundingRect.left + rootItemBoundingRect.width * 1.5,
|
|
450
|
+
rootItemBoundingRect.top + rootItemBoundingRect.height / 2
|
|
451
|
+
]
|
|
452
|
+
}
|
|
453
|
+
]
|
|
454
|
+
});
|
|
455
|
+
await opened;
|
|
456
|
+
expect(rootItem.open).to.be.true;
|
|
457
|
+
});
|
|
458
|
+
it("not opens if disabled", async () => {
|
|
459
|
+
const el = await styledFixture(html`
|
|
491
460
|
<sp-menu>
|
|
492
461
|
<sp-menu-item disabled class="root">
|
|
493
462
|
Has submenu
|
|
@@ -505,29 +474,26 @@ describe('Submenu', () => {
|
|
|
505
474
|
</sp-menu-item>
|
|
506
475
|
</sp-menu>
|
|
507
476
|
`);
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
},
|
|
523
|
-
],
|
|
524
|
-
});
|
|
525
|
-
// wait 200ms for open
|
|
526
|
-
await new Promise((r) => setTimeout(r, 200));
|
|
527
|
-
expect(rootItem.open).to.be.false;
|
|
477
|
+
await elementUpdated(el);
|
|
478
|
+
const rootItem = el.querySelector(".root");
|
|
479
|
+
const rootItemBoundingRect = rootItem.getBoundingClientRect();
|
|
480
|
+
expect(rootItem.open).to.be.false;
|
|
481
|
+
sendMouse({
|
|
482
|
+
steps: [
|
|
483
|
+
{
|
|
484
|
+
type: "move",
|
|
485
|
+
position: [
|
|
486
|
+
rootItemBoundingRect.left + rootItemBoundingRect.width / 2,
|
|
487
|
+
rootItemBoundingRect.top + rootItemBoundingRect.height / 2
|
|
488
|
+
]
|
|
489
|
+
}
|
|
490
|
+
]
|
|
528
491
|
});
|
|
529
|
-
|
|
530
|
-
|
|
492
|
+
await new Promise((r) => setTimeout(r, 200));
|
|
493
|
+
expect(rootItem.open).to.be.false;
|
|
494
|
+
});
|
|
495
|
+
it("closes all decendent submenus when closing a ancestor menu", async () => {
|
|
496
|
+
const el = await styledFixture(html`
|
|
531
497
|
<sp-action-menu>
|
|
532
498
|
<sp-icon-show-menu slot="icon"></sp-icon-show-menu>
|
|
533
499
|
<sp-menu-group role="none">
|
|
@@ -566,38 +532,38 @@ describe('Submenu', () => {
|
|
|
566
532
|
</sp-menu-group>
|
|
567
533
|
</sp-action-menu>
|
|
568
534
|
`);
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
535
|
+
const rootMenu1 = el.querySelector("#submenu-item-1");
|
|
536
|
+
const rootMenu2 = el.querySelector("#submenu-item-3");
|
|
537
|
+
const childMenu2 = el.querySelector("#submenu-item-2");
|
|
538
|
+
expect(el.open).to.be.false;
|
|
539
|
+
let opened = oneEvent(el, "sp-opened");
|
|
540
|
+
el.click();
|
|
541
|
+
await opened;
|
|
542
|
+
expect(el.open).to.be.true;
|
|
543
|
+
let activeOverlays = document.querySelectorAll("active-overlay");
|
|
544
|
+
expect(activeOverlays.length).to.equal(1);
|
|
545
|
+
opened = oneEvent(rootMenu1, "sp-opened");
|
|
546
|
+
rootMenu1.dispatchEvent(new PointerEvent("pointerenter", { bubbles: true }));
|
|
547
|
+
await opened;
|
|
548
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
549
|
+
expect(activeOverlays.length).to.equal(2);
|
|
550
|
+
opened = oneEvent(childMenu2, "sp-opened");
|
|
551
|
+
childMenu2.dispatchEvent(new PointerEvent("pointerenter", { bubbles: true }));
|
|
552
|
+
await opened;
|
|
553
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
554
|
+
expect(activeOverlays.length).to.equal(3);
|
|
555
|
+
const overlaysManaged = Promise.all([
|
|
556
|
+
oneEvent(childMenu2, "sp-closed"),
|
|
557
|
+
oneEvent(rootMenu1, "sp-closed"),
|
|
558
|
+
oneEvent(rootMenu2, "sp-opened")
|
|
559
|
+
]);
|
|
560
|
+
rootMenu2.dispatchEvent(new PointerEvent("pointerenter", { bubbles: true }));
|
|
561
|
+
await overlaysManaged;
|
|
562
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
563
|
+
expect(activeOverlays.length).to.equal(2);
|
|
564
|
+
});
|
|
565
|
+
it("closes back to the first overlay without a `root` when clicking away", async () => {
|
|
566
|
+
const el = await styledFixture(html`
|
|
601
567
|
<sp-action-menu>
|
|
602
568
|
<sp-icon-show-menu slot="icon"></sp-icon-show-menu>
|
|
603
569
|
<sp-menu-group role="none">
|
|
@@ -636,37 +602,87 @@ describe('Submenu', () => {
|
|
|
636
602
|
</sp-menu-group>
|
|
637
603
|
</sp-action-menu>
|
|
638
604
|
`);
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
605
|
+
const rootMenu1 = el.querySelector("#submenu-item-1");
|
|
606
|
+
const childMenu2 = el.querySelector("#submenu-item-2");
|
|
607
|
+
expect(el.open).to.be.false;
|
|
608
|
+
let opened = oneEvent(el, "sp-opened");
|
|
609
|
+
el.click();
|
|
610
|
+
await opened;
|
|
611
|
+
expect(el.open).to.be.true;
|
|
612
|
+
let activeOverlays = document.querySelectorAll("active-overlay");
|
|
613
|
+
expect(activeOverlays.length).to.equal(1);
|
|
614
|
+
opened = oneEvent(rootMenu1, "sp-opened");
|
|
615
|
+
rootMenu1.dispatchEvent(new PointerEvent("pointerenter", { bubbles: true }));
|
|
616
|
+
await opened;
|
|
617
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
618
|
+
expect(activeOverlays.length).to.equal(2);
|
|
619
|
+
opened = oneEvent(childMenu2, "sp-opened");
|
|
620
|
+
childMenu2.dispatchEvent(new PointerEvent("pointerenter", { bubbles: true }));
|
|
621
|
+
await opened;
|
|
622
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
623
|
+
expect(activeOverlays.length).to.equal(3);
|
|
624
|
+
const closed = Promise.all([
|
|
625
|
+
oneEvent(childMenu2, "sp-closed"),
|
|
626
|
+
oneEvent(rootMenu1, "sp-closed"),
|
|
627
|
+
oneEvent(el, "sp-closed")
|
|
628
|
+
]);
|
|
629
|
+
document.body.click();
|
|
630
|
+
await closed;
|
|
631
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
632
|
+
expect(activeOverlays.length).to.equal(0);
|
|
633
|
+
});
|
|
634
|
+
it("closes decendent menus when Menu Item in ancestor without a submenu is pointerentered", async () => {
|
|
635
|
+
const el = await styledFixture(html`
|
|
636
|
+
<sp-action-menu>
|
|
637
|
+
<sp-icon-show-menu slot="icon"></sp-icon-show-menu>
|
|
638
|
+
<sp-menu-group role="none">
|
|
639
|
+
<span slot="header">New York</span>
|
|
640
|
+
<sp-menu-item id="no-submenu">Bronx</sp-menu-item>
|
|
641
|
+
<sp-menu-item id="submenu-item-1">
|
|
642
|
+
Brooklyn
|
|
643
|
+
<sp-menu slot="submenu">
|
|
644
|
+
<sp-menu-item id="submenu-item-2">
|
|
645
|
+
Ft. Greene
|
|
646
|
+
</sp-menu-item>
|
|
647
|
+
<sp-menu-item disabled>Park Slope</sp-menu-item>
|
|
648
|
+
<sp-menu-item id="ancestor-item">
|
|
649
|
+
Williamsburg
|
|
650
|
+
</sp-menu-item>
|
|
651
|
+
</sp-menu>
|
|
652
|
+
</sp-menu-item>
|
|
653
|
+
<sp-menu-item id="submenu-item-3">
|
|
654
|
+
Manhattan
|
|
655
|
+
<sp-menu slot="submenu">
|
|
656
|
+
<sp-menu-item disabled>SoHo</sp-menu-item>
|
|
657
|
+
<sp-menu-item>Union Square</sp-menu-item>
|
|
658
|
+
<sp-menu-item>Upper East Side</sp-menu-item>
|
|
659
|
+
</sp-menu>
|
|
660
|
+
</sp-menu-item>
|
|
661
|
+
</sp-menu-group>
|
|
662
|
+
</sp-action-menu>
|
|
663
|
+
`);
|
|
664
|
+
const rootMenu = el.querySelector("#submenu-item-1");
|
|
665
|
+
const noSubmenu = el.querySelector("#no-submenu");
|
|
666
|
+
expect(el.open).to.be.false;
|
|
667
|
+
let opened = oneEvent(el, "sp-opened");
|
|
668
|
+
el.click();
|
|
669
|
+
await opened;
|
|
670
|
+
expect(el.open).to.be.true;
|
|
671
|
+
let activeOverlays = document.querySelectorAll("active-overlay");
|
|
672
|
+
expect(activeOverlays.length).to.equal(1);
|
|
673
|
+
opened = oneEvent(rootMenu, "sp-opened");
|
|
674
|
+
rootMenu.dispatchEvent(new PointerEvent("pointerenter", { bubbles: true }));
|
|
675
|
+
await opened;
|
|
676
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
677
|
+
expect(activeOverlays.length).to.equal(2);
|
|
678
|
+
const closed = oneEvent(rootMenu, "sp-closed");
|
|
679
|
+
noSubmenu.dispatchEvent(new PointerEvent("pointerenter", { bubbles: true }));
|
|
680
|
+
await closed;
|
|
681
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
682
|
+
expect(activeOverlays.length).to.equal(1);
|
|
683
|
+
});
|
|
684
|
+
it("closes decendent menus when Menu Item in ancestor is clicked", async () => {
|
|
685
|
+
const el = await styledFixture(html`
|
|
670
686
|
<sp-action-menu>
|
|
671
687
|
<sp-icon-show-menu slot="icon"></sp-icon-show-menu>
|
|
672
688
|
<sp-menu-group role="none">
|
|
@@ -707,35 +723,35 @@ describe('Submenu', () => {
|
|
|
707
723
|
</sp-menu-group>
|
|
708
724
|
</sp-action-menu>
|
|
709
725
|
`);
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
726
|
+
const rootMenu1 = el.querySelector("#submenu-item-1");
|
|
727
|
+
const childMenu2 = el.querySelector("#submenu-item-2");
|
|
728
|
+
const ancestorItem = el.querySelector("#ancestor-item");
|
|
729
|
+
expect(el.open).to.be.false;
|
|
730
|
+
let opened = oneEvent(el, "sp-opened");
|
|
731
|
+
el.click();
|
|
732
|
+
await opened;
|
|
733
|
+
expect(el.open).to.be.true;
|
|
734
|
+
let activeOverlays = document.querySelectorAll("active-overlay");
|
|
735
|
+
expect(activeOverlays.length).to.equal(1);
|
|
736
|
+
opened = oneEvent(rootMenu1, "sp-opened");
|
|
737
|
+
rootMenu1.dispatchEvent(new PointerEvent("pointerenter", { bubbles: true }));
|
|
738
|
+
await opened;
|
|
739
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
740
|
+
expect(activeOverlays.length).to.equal(2);
|
|
741
|
+
opened = oneEvent(childMenu2, "sp-opened");
|
|
742
|
+
childMenu2.dispatchEvent(new PointerEvent("pointerenter", { bubbles: true }));
|
|
743
|
+
await opened;
|
|
744
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
745
|
+
expect(activeOverlays.length).to.equal(3);
|
|
746
|
+
const closed = Promise.all([
|
|
747
|
+
oneEvent(childMenu2, "sp-closed"),
|
|
748
|
+
oneEvent(rootMenu1, "sp-closed"),
|
|
749
|
+
oneEvent(el, "sp-closed")
|
|
750
|
+
]);
|
|
751
|
+
ancestorItem.click();
|
|
752
|
+
await closed;
|
|
753
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
754
|
+
expect(activeOverlays.length).to.equal(0);
|
|
755
|
+
});
|
|
740
756
|
});
|
|
741
|
-
//# sourceMappingURL=submenu.test.js.map
|
|
757
|
+
//# sourceMappingURL=submenu.test.js.map
|