@spectrum-web-components/menu 0.35.1-rc.43 → 0.36.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 +2276 -0
- package/package.json +10 -10
- package/src/Menu.d.ts +12 -17
- package/src/Menu.dev.js +64 -164
- package/src/Menu.dev.js.map +2 -2
- package/src/Menu.js +3 -7
- package/src/Menu.js.map +3 -3
- package/src/MenuGroup.d.ts +2 -0
- package/src/MenuGroup.dev.js +12 -8
- package/src/MenuGroup.dev.js.map +2 -2
- package/src/MenuGroup.js +5 -3
- package/src/MenuGroup.js.map +3 -3
- package/src/MenuItem.d.ts +32 -31
- package/src/MenuItem.dev.js +232 -197
- package/src/MenuItem.dev.js.map +3 -3
- package/src/MenuItem.js +25 -39
- package/src/MenuItem.js.map +3 -3
- package/src/menu-divider.css.dev.js +5 -1
- package/src/menu-divider.css.dev.js.map +2 -2
- package/src/menu-divider.css.js +7 -3
- package/src/menu-divider.css.js.map +2 -2
- package/src/menu-group.css.dev.js +23 -1
- package/src/menu-group.css.dev.js.map +2 -2
- package/src/menu-group.css.js +25 -3
- package/src/menu-group.css.js.map +2 -2
- package/src/menu-item.css.dev.js +302 -60
- package/src/menu-item.css.dev.js.map +2 -2
- package/src/menu-item.css.js +304 -62
- package/src/menu-item.css.js.map +2 -2
- package/src/menu.css.dev.js +181 -48
- package/src/menu.css.dev.js.map +2 -2
- package/src/menu.css.js +183 -50
- package/src/menu.css.js.map +2 -2
- package/src/spectrum-checkmark.css.dev.js +23 -1
- package/src/spectrum-checkmark.css.dev.js.map +2 -2
- package/src/spectrum-checkmark.css.js +25 -3
- package/src/spectrum-checkmark.css.js.map +2 -2
- package/src/spectrum-chevron.css.dev.js +3 -1
- package/src/spectrum-chevron.css.dev.js.map +2 -2
- package/src/spectrum-chevron.css.js +5 -3
- package/src/spectrum-chevron.css.js.map +2 -2
- package/src/spectrum-config.js +258 -79
- package/src/spectrum-menu-divider.css.dev.js +5 -1
- package/src/spectrum-menu-divider.css.dev.js.map +2 -2
- package/src/spectrum-menu-divider.css.js +7 -3
- package/src/spectrum-menu-divider.css.js.map +2 -2
- package/src/spectrum-menu-item.css.dev.js +302 -60
- package/src/spectrum-menu-item.css.dev.js.map +2 -2
- package/src/spectrum-menu-item.css.js +304 -62
- package/src/spectrum-menu-item.css.js.map +2 -2
- package/src/spectrum-menu-sectionHeading.css.dev.js +23 -1
- package/src/spectrum-menu-sectionHeading.css.dev.js.map +2 -2
- package/src/spectrum-menu-sectionHeading.css.js +25 -3
- package/src/spectrum-menu-sectionHeading.css.js.map +2 -2
- package/src/spectrum-menu.css.dev.js +180 -47
- package/src/spectrum-menu.css.dev.js.map +2 -2
- package/src/spectrum-menu.css.js +182 -49
- package/src/spectrum-menu.css.js.map +2 -2
- package/stories/index.js +30 -0
- package/stories/index.js.map +7 -0
- package/stories/menu-sizes.stories.js +11 -0
- package/stories/menu-sizes.stories.js.map +7 -0
- package/stories/menu.stories.js +24 -1
- package/stories/menu.stories.js.map +2 -2
- package/stories/submenu.stories.js +104 -117
- package/stories/submenu.stories.js.map +3 -3
- package/test/menu-group.test.js +1 -14
- package/test/menu-group.test.js.map +2 -2
- package/test/menu-item.test.js +0 -22
- package/test/menu-item.test.js.map +2 -2
- package/test/menu-selects.test.js +1 -3
- package/test/menu-selects.test.js.map +2 -2
- package/test/menu-sizes.test-vrt.js +5 -0
- package/test/menu-sizes.test-vrt.js.map +7 -0
- package/test/menu.test.js +0 -7
- package/test/menu.test.js.map +2 -2
- package/test/submenu.test.js +84 -206
- package/test/submenu.test.js.map +2 -2
package/test/submenu.test.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import "@spectrum-web-components/menu/sp-menu.js";
|
|
3
3
|
import "@spectrum-web-components/menu/sp-menu-item.js";
|
|
4
4
|
import {
|
|
5
|
-
aTimeout,
|
|
6
5
|
elementUpdated,
|
|
7
6
|
expect,
|
|
8
7
|
fixture,
|
|
@@ -20,40 +19,7 @@ import "@spectrum-web-components/menu/sp-menu-group.js";
|
|
|
20
19
|
import "@spectrum-web-components/icons-workflow/icons/sp-icon-show-menu.js";
|
|
21
20
|
async function styledFixture(story, dir = "ltr") {
|
|
22
21
|
const test = await fixture(html`
|
|
23
|
-
<sp-theme dir=${dir} scale="medium" color="dark">
|
|
24
|
-
${story}
|
|
25
|
-
<style>
|
|
26
|
-
sp-theme {
|
|
27
|
-
--spectrum-global-animation-duration-100: 50ms;
|
|
28
|
-
--spectrum-global-animation-duration-200: 50ms;
|
|
29
|
-
--spectrum-global-animation-duration-300: 50ms;
|
|
30
|
-
--spectrum-global-animation-duration-400: 50ms;
|
|
31
|
-
--spectrum-global-animation-duration-500: 50ms;
|
|
32
|
-
--spectrum-global-animation-duration-600: 50ms;
|
|
33
|
-
--spectrum-global-animation-duration-700: 50ms;
|
|
34
|
-
--spectrum-global-animation-duration-800: 50ms;
|
|
35
|
-
--spectrum-global-animation-duration-900: 50ms;
|
|
36
|
-
--spectrum-global-animation-duration-1000: 50ms;
|
|
37
|
-
--spectrum-global-animation-duration-2000: 50ms;
|
|
38
|
-
--spectrum-global-animation-duration-4000: 50ms;
|
|
39
|
-
--spectrum-animation-duration-0: 50ms;
|
|
40
|
-
--spectrum-animation-duration-100: 50ms;
|
|
41
|
-
--spectrum-animation-duration-200: 50ms;
|
|
42
|
-
--spectrum-animation-duration-300: 50ms;
|
|
43
|
-
--spectrum-animation-duration-400: 50ms;
|
|
44
|
-
--spectrum-animation-duration-500: 50ms;
|
|
45
|
-
--spectrum-animation-duration-600: 50ms;
|
|
46
|
-
--spectrum-animation-duration-700: 50ms;
|
|
47
|
-
--spectrum-animation-duration-800: 50ms;
|
|
48
|
-
--spectrum-animation-duration-900: 50ms;
|
|
49
|
-
--spectrum-animation-duration-1000: 50ms;
|
|
50
|
-
--spectrum-animation-duration-2000: 50ms;
|
|
51
|
-
--spectrum-animation-duration-4000: 50ms;
|
|
52
|
-
--spectrum-coachmark-animation-indicator-ring-duration: 50ms;
|
|
53
|
-
--swc-test-duration: 1ms;
|
|
54
|
-
}
|
|
55
|
-
</style>
|
|
56
|
-
</sp-theme>
|
|
22
|
+
<sp-theme dir=${dir} scale="medium" color="dark">${story}</sp-theme>
|
|
57
23
|
`);
|
|
58
24
|
document.documentElement.dir = dir;
|
|
59
25
|
return test.children[0];
|
|
@@ -124,8 +90,9 @@ describe("Submenu", () => {
|
|
|
124
90
|
]
|
|
125
91
|
});
|
|
126
92
|
await closed;
|
|
127
|
-
|
|
128
|
-
expect(rootChanged.
|
|
93
|
+
await nextFrame();
|
|
94
|
+
expect(rootChanged.calledWith("Has submenu"), "root changed").to.be.true;
|
|
95
|
+
expect(submenuChanged.calledWith("Two"), "submenu changed").to.be.true;
|
|
129
96
|
});
|
|
130
97
|
it("closes deep tree on selection", async () => {
|
|
131
98
|
const rootChanged = spy();
|
|
@@ -176,12 +143,11 @@ describe("Submenu", () => {
|
|
|
176
143
|
</sp-menu>
|
|
177
144
|
`
|
|
178
145
|
);
|
|
146
|
+
await elementUpdated(el);
|
|
179
147
|
const rootItem = el.querySelector(".root");
|
|
180
148
|
const rootItemBoundingRect = rootItem.getBoundingClientRect();
|
|
181
|
-
const item2 = document.querySelector(".submenu-item-2");
|
|
182
|
-
const itemC = document.querySelector(".sub-submenu-item-3");
|
|
183
149
|
expect(rootItem.open).to.be.false;
|
|
184
|
-
|
|
150
|
+
const opened = oneEvent(rootItem, "sp-opened");
|
|
185
151
|
sendMouse({
|
|
186
152
|
steps: [
|
|
187
153
|
{
|
|
@@ -195,8 +161,9 @@ describe("Submenu", () => {
|
|
|
195
161
|
});
|
|
196
162
|
await opened;
|
|
197
163
|
expect(rootItem.open).to.be.true;
|
|
164
|
+
const item2 = document.querySelector(".submenu-item-2");
|
|
198
165
|
const item2BoundingRect = item2.getBoundingClientRect();
|
|
199
|
-
|
|
166
|
+
let closed = oneEvent(item2, "sp-opened");
|
|
200
167
|
sendMouse({
|
|
201
168
|
steps: [
|
|
202
169
|
{
|
|
@@ -208,11 +175,25 @@ describe("Submenu", () => {
|
|
|
208
175
|
}
|
|
209
176
|
]
|
|
210
177
|
});
|
|
211
|
-
await
|
|
178
|
+
await closed;
|
|
179
|
+
await nextFrame();
|
|
212
180
|
expect(item2.open).to.be.true;
|
|
213
|
-
const
|
|
214
|
-
itemC.
|
|
181
|
+
const itemC = document.querySelector(".sub-submenu-item-3");
|
|
182
|
+
const itemCBoundingRect = itemC.getBoundingClientRect();
|
|
183
|
+
closed = oneEvent(rootItem, "sp-closed");
|
|
184
|
+
sendMouse({
|
|
185
|
+
steps: [
|
|
186
|
+
{
|
|
187
|
+
type: "click",
|
|
188
|
+
position: [
|
|
189
|
+
itemCBoundingRect.left + itemCBoundingRect.width / 2,
|
|
190
|
+
itemCBoundingRect.top + itemCBoundingRect.height / 2
|
|
191
|
+
]
|
|
192
|
+
}
|
|
193
|
+
]
|
|
194
|
+
});
|
|
215
195
|
await closed;
|
|
196
|
+
await nextFrame();
|
|
216
197
|
expect(rootChanged.calledWith("Has submenu"), "root changed").to.be.true;
|
|
217
198
|
expect(submenuChanged.calledWith("Two"), "submenu changed").to.be.true;
|
|
218
199
|
expect(subSubmenuChanged.calledWith("C"), "sub submenu changed").to.be.true;
|
|
@@ -229,14 +210,12 @@ describe("Submenu", () => {
|
|
|
229
210
|
closeKey: "ArrowRight"
|
|
230
211
|
}
|
|
231
212
|
].map((testData) => {
|
|
232
|
-
it(`selects - keyboard: ${testData.dir}`, async
|
|
233
|
-
var _a, _b;
|
|
213
|
+
it(`selects - keyboard: ${testData.dir}`, async () => {
|
|
234
214
|
const rootChanged = spy();
|
|
235
215
|
const submenuChanged = spy();
|
|
236
216
|
const el = await styledFixture(
|
|
237
217
|
html`
|
|
238
218
|
<sp-menu
|
|
239
|
-
id="base"
|
|
240
219
|
@change=${(event) => {
|
|
241
220
|
rootChanged(event.target.value);
|
|
242
221
|
}}
|
|
@@ -244,7 +223,6 @@ describe("Submenu", () => {
|
|
|
244
223
|
<sp-menu-item class="root">
|
|
245
224
|
Has submenu
|
|
246
225
|
<sp-menu
|
|
247
|
-
id="sub"
|
|
248
226
|
slot="submenu"
|
|
249
227
|
@change=${(event) => {
|
|
250
228
|
submenuChanged(event.target.value);
|
|
@@ -267,8 +245,6 @@ describe("Submenu", () => {
|
|
|
267
245
|
);
|
|
268
246
|
await elementUpdated(el);
|
|
269
247
|
const rootItem = el.querySelector(".root");
|
|
270
|
-
const submenu = el.querySelector('[slot="submenu"]');
|
|
271
|
-
const submenuItem = el.querySelector(".submenu-item-2");
|
|
272
248
|
expect(rootItem.open).to.be.false;
|
|
273
249
|
el.focus();
|
|
274
250
|
await elementUpdated(el);
|
|
@@ -278,20 +254,12 @@ describe("Submenu", () => {
|
|
|
278
254
|
});
|
|
279
255
|
await opened;
|
|
280
256
|
expect(rootItem.open).to.be.true;
|
|
281
|
-
expect(
|
|
282
|
-
submenu === document.activeElement,
|
|
283
|
-
`${(_a = document.activeElement) == null ? void 0 : _a.id}`
|
|
284
|
-
).to.be.true;
|
|
285
257
|
let closed = oneEvent(rootItem, "sp-closed");
|
|
286
258
|
sendKeys({
|
|
287
259
|
press: testData.closeKey
|
|
288
260
|
});
|
|
289
261
|
await closed;
|
|
290
262
|
expect(rootItem.open).to.be.false;
|
|
291
|
-
expect(
|
|
292
|
-
el === document.activeElement,
|
|
293
|
-
`${(_b = document.activeElement) == null ? void 0 : _b.id}`
|
|
294
|
-
).to.be.true;
|
|
295
263
|
opened = oneEvent(rootItem, "sp-opened");
|
|
296
264
|
sendKeys({
|
|
297
265
|
press: testData.openKey
|
|
@@ -301,23 +269,13 @@ describe("Submenu", () => {
|
|
|
301
269
|
await sendKeys({
|
|
302
270
|
press: "ArrowDown"
|
|
303
271
|
});
|
|
304
|
-
await elementUpdated(submenuItem);
|
|
305
|
-
await nextFrame();
|
|
306
|
-
await nextFrame();
|
|
307
|
-
expect(submenu.getAttribute("aria-activedescendant")).to.equal(
|
|
308
|
-
submenuItem.id
|
|
309
|
-
);
|
|
310
272
|
closed = oneEvent(rootItem, "sp-closed");
|
|
311
273
|
sendKeys({
|
|
312
274
|
press: "Enter"
|
|
313
275
|
});
|
|
314
276
|
await closed;
|
|
277
|
+
expect(rootChanged.calledWith("Has submenu"), "root changed").to.be.true;
|
|
315
278
|
expect(submenuChanged.calledWith("Two"), "submenu changed").to.be.true;
|
|
316
|
-
expect(rootChanged.called, "root has changed").to.be.true;
|
|
317
|
-
expect(
|
|
318
|
-
rootChanged.calledWith("Has submenu"),
|
|
319
|
-
"root specifically changed"
|
|
320
|
-
).to.be.true;
|
|
321
279
|
});
|
|
322
280
|
});
|
|
323
281
|
it("closes on `pointerleave`", async () => {
|
|
@@ -449,8 +407,7 @@ describe("Submenu", () => {
|
|
|
449
407
|
});
|
|
450
408
|
await closed;
|
|
451
409
|
});
|
|
452
|
-
it("
|
|
453
|
-
const clickSpy = spy();
|
|
410
|
+
it("stays open when mousing between menu item and submenu", async () => {
|
|
454
411
|
const el = await styledFixture(
|
|
455
412
|
html`
|
|
456
413
|
<sp-menu>
|
|
@@ -460,10 +417,7 @@ describe("Submenu", () => {
|
|
|
460
417
|
<sp-menu-item class="submenu-item-1">
|
|
461
418
|
One
|
|
462
419
|
</sp-menu-item>
|
|
463
|
-
<sp-menu-item
|
|
464
|
-
class="submenu-item-2"
|
|
465
|
-
@click=${() => clickSpy()}
|
|
466
|
-
>
|
|
420
|
+
<sp-menu-item class="submenu-item-2">
|
|
467
421
|
Two
|
|
468
422
|
</sp-menu-item>
|
|
469
423
|
<sp-menu-item class="submenu-item-3">
|
|
@@ -476,7 +430,6 @@ describe("Submenu", () => {
|
|
|
476
430
|
);
|
|
477
431
|
await elementUpdated(el);
|
|
478
432
|
const rootItem = el.querySelector(".root");
|
|
479
|
-
const subItem = el.querySelector(".submenu-item-2");
|
|
480
433
|
const rootItemBoundingRect = rootItem.getBoundingClientRect();
|
|
481
434
|
expect(rootItem.open).to.be.false;
|
|
482
435
|
const opened = oneEvent(rootItem, "sp-opened");
|
|
@@ -491,114 +444,30 @@ describe("Submenu", () => {
|
|
|
491
444
|
}
|
|
492
445
|
]
|
|
493
446
|
});
|
|
494
|
-
await nextFrame();
|
|
495
|
-
await nextFrame();
|
|
496
|
-
const subItemBoundingRect = subItem.getBoundingClientRect();
|
|
497
447
|
await sendMouse({
|
|
498
448
|
steps: [
|
|
499
449
|
{
|
|
500
450
|
type: "move",
|
|
501
451
|
position: [
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
]
|
|
505
|
-
}
|
|
506
|
-
]
|
|
507
|
-
});
|
|
508
|
-
await opened;
|
|
509
|
-
expect(rootItem.open).to.be.true;
|
|
510
|
-
await aTimeout(150);
|
|
511
|
-
expect(rootItem.open).to.be.true;
|
|
512
|
-
const closed = oneEvent(rootItem, "sp-closed");
|
|
513
|
-
sendMouse({
|
|
514
|
-
steps: [
|
|
515
|
-
{
|
|
516
|
-
type: "click",
|
|
517
|
-
position: [
|
|
518
|
-
subItemBoundingRect.left + subItemBoundingRect.width / 2,
|
|
519
|
-
subItemBoundingRect.top + subItemBoundingRect.height / 2
|
|
452
|
+
rootItemBoundingRect.left + rootItemBoundingRect.width / 2,
|
|
453
|
+
rootItemBoundingRect.top + rootItemBoundingRect.height * 2
|
|
520
454
|
]
|
|
521
455
|
}
|
|
522
456
|
]
|
|
523
457
|
});
|
|
524
|
-
await closed;
|
|
525
|
-
expect(clickSpy.callCount).to.equal(1);
|
|
526
|
-
});
|
|
527
|
-
it("stays open when mousing between menu item and submenu", async () => {
|
|
528
|
-
const clickSpy = spy();
|
|
529
|
-
const el = await styledFixture(
|
|
530
|
-
html`
|
|
531
|
-
<sp-menu>
|
|
532
|
-
<sp-menu-item class="root">
|
|
533
|
-
Has submenu
|
|
534
|
-
<sp-menu slot="submenu">
|
|
535
|
-
<sp-menu-item class="submenu-item-1">
|
|
536
|
-
One
|
|
537
|
-
</sp-menu-item>
|
|
538
|
-
<sp-menu-item
|
|
539
|
-
class="submenu-item-2"
|
|
540
|
-
@click=${() => clickSpy()}
|
|
541
|
-
>
|
|
542
|
-
Two
|
|
543
|
-
</sp-menu-item>
|
|
544
|
-
<sp-menu-item class="submenu-item-3">
|
|
545
|
-
Three
|
|
546
|
-
</sp-menu-item>
|
|
547
|
-
</sp-menu>
|
|
548
|
-
</sp-menu-item>
|
|
549
|
-
</sp-menu>
|
|
550
|
-
`
|
|
551
|
-
);
|
|
552
|
-
await elementUpdated(el);
|
|
553
|
-
const rootItem = el.querySelector(".root");
|
|
554
|
-
const subItem = el.querySelector(".submenu-item-2");
|
|
555
|
-
const rootItemBoundingRect = rootItem.getBoundingClientRect();
|
|
556
|
-
expect(rootItem.open).to.be.false;
|
|
557
|
-
const opened = oneEvent(rootItem, "sp-opened");
|
|
558
458
|
await sendMouse({
|
|
559
459
|
steps: [
|
|
560
460
|
{
|
|
561
461
|
type: "move",
|
|
562
462
|
position: [
|
|
563
|
-
rootItemBoundingRect.left + rootItemBoundingRect.width
|
|
463
|
+
rootItemBoundingRect.left + rootItemBoundingRect.width * 1.5,
|
|
564
464
|
rootItemBoundingRect.top + rootItemBoundingRect.height / 2
|
|
565
465
|
]
|
|
566
466
|
}
|
|
567
467
|
]
|
|
568
468
|
});
|
|
569
469
|
await opened;
|
|
570
|
-
await nextFrame();
|
|
571
|
-
await nextFrame();
|
|
572
|
-
const subItemBoundingRect = subItem.getBoundingClientRect();
|
|
573
470
|
expect(rootItem.open).to.be.true;
|
|
574
|
-
await sendMouse({
|
|
575
|
-
steps: [
|
|
576
|
-
{
|
|
577
|
-
type: "move",
|
|
578
|
-
position: [
|
|
579
|
-
subItemBoundingRect.left + subItemBoundingRect.width / 2,
|
|
580
|
-
subItemBoundingRect.top + subItemBoundingRect.height / 2
|
|
581
|
-
]
|
|
582
|
-
}
|
|
583
|
-
]
|
|
584
|
-
});
|
|
585
|
-
expect(rootItem.open).to.be.true;
|
|
586
|
-
await aTimeout(150);
|
|
587
|
-
expect(rootItem.open).to.be.true;
|
|
588
|
-
const closed = oneEvent(rootItem, "sp-closed");
|
|
589
|
-
sendMouse({
|
|
590
|
-
steps: [
|
|
591
|
-
{
|
|
592
|
-
type: "click",
|
|
593
|
-
position: [
|
|
594
|
-
subItemBoundingRect.left + subItemBoundingRect.width / 2,
|
|
595
|
-
subItemBoundingRect.top + subItemBoundingRect.height / 2
|
|
596
|
-
]
|
|
597
|
-
}
|
|
598
|
-
]
|
|
599
|
-
});
|
|
600
|
-
await closed;
|
|
601
|
-
expect(clickSpy.callCount).to.equal(1);
|
|
602
471
|
});
|
|
603
472
|
it("not opens if disabled", async () => {
|
|
604
473
|
const el = await styledFixture(
|
|
@@ -643,15 +512,15 @@ describe("Submenu", () => {
|
|
|
643
512
|
const el = await styledFixture(html`
|
|
644
513
|
<sp-action-menu>
|
|
645
514
|
<sp-icon-show-menu slot="icon"></sp-icon-show-menu>
|
|
646
|
-
<sp-menu-group role="none"
|
|
515
|
+
<sp-menu-group role="none">
|
|
647
516
|
<span slot="header">New York</span>
|
|
648
517
|
<sp-menu-item>Bronx</sp-menu-item>
|
|
649
518
|
<sp-menu-item id="submenu-item-1">
|
|
650
519
|
Brooklyn
|
|
651
|
-
<sp-menu slot="submenu"
|
|
520
|
+
<sp-menu slot="submenu">
|
|
652
521
|
<sp-menu-item id="submenu-item-2">
|
|
653
522
|
Ft. Greene
|
|
654
|
-
<sp-menu slot="submenu"
|
|
523
|
+
<sp-menu slot="submenu">
|
|
655
524
|
<sp-menu-item>S. Oxford St</sp-menu-item>
|
|
656
525
|
<sp-menu-item>S. Portland Ave</sp-menu-item>
|
|
657
526
|
<sp-menu-item>S. Elliot Pl</sp-menu-item>
|
|
@@ -663,7 +532,7 @@ describe("Submenu", () => {
|
|
|
663
532
|
</sp-menu-item>
|
|
664
533
|
<sp-menu-item id="submenu-item-3">
|
|
665
534
|
Manhattan
|
|
666
|
-
<sp-menu slot="submenu"
|
|
535
|
+
<sp-menu slot="submenu">
|
|
667
536
|
<sp-menu-item disabled>SoHo</sp-menu-item>
|
|
668
537
|
<sp-menu-item>
|
|
669
538
|
Union Square
|
|
@@ -687,27 +556,33 @@ describe("Submenu", () => {
|
|
|
687
556
|
el.click();
|
|
688
557
|
await opened;
|
|
689
558
|
expect(el.open).to.be.true;
|
|
559
|
+
let activeOverlays = document.querySelectorAll("active-overlay");
|
|
560
|
+
expect(activeOverlays.length).to.equal(1);
|
|
690
561
|
opened = oneEvent(rootMenu1, "sp-opened");
|
|
691
562
|
rootMenu1.dispatchEvent(
|
|
692
563
|
new PointerEvent("pointerenter", { bubbles: true })
|
|
693
564
|
);
|
|
694
565
|
await opened;
|
|
695
|
-
|
|
566
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
567
|
+
expect(activeOverlays.length).to.equal(2);
|
|
696
568
|
opened = oneEvent(childMenu2, "sp-opened");
|
|
697
569
|
childMenu2.dispatchEvent(
|
|
698
570
|
new PointerEvent("pointerenter", { bubbles: true })
|
|
699
571
|
);
|
|
700
572
|
await opened;
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
const
|
|
704
|
-
|
|
573
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
574
|
+
expect(activeOverlays.length).to.equal(3);
|
|
575
|
+
const overlaysManaged = Promise.all([
|
|
576
|
+
oneEvent(childMenu2, "sp-closed"),
|
|
577
|
+
oneEvent(rootMenu1, "sp-closed"),
|
|
578
|
+
oneEvent(rootMenu2, "sp-opened")
|
|
579
|
+
]);
|
|
705
580
|
rootMenu2.dispatchEvent(
|
|
706
581
|
new PointerEvent("pointerenter", { bubbles: true })
|
|
707
582
|
);
|
|
708
|
-
await
|
|
709
|
-
|
|
710
|
-
|
|
583
|
+
await overlaysManaged;
|
|
584
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
585
|
+
expect(activeOverlays.length).to.equal(2);
|
|
711
586
|
});
|
|
712
587
|
it("closes back to the first overlay without a `root` when clicking away", async () => {
|
|
713
588
|
const el = await styledFixture(html`
|
|
@@ -756,30 +631,31 @@ describe("Submenu", () => {
|
|
|
756
631
|
el.click();
|
|
757
632
|
await opened;
|
|
758
633
|
expect(el.open).to.be.true;
|
|
634
|
+
let activeOverlays = document.querySelectorAll("active-overlay");
|
|
635
|
+
expect(activeOverlays.length).to.equal(1);
|
|
759
636
|
opened = oneEvent(rootMenu1, "sp-opened");
|
|
760
637
|
rootMenu1.dispatchEvent(
|
|
761
638
|
new PointerEvent("pointerenter", { bubbles: true })
|
|
762
639
|
);
|
|
763
640
|
await opened;
|
|
641
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
642
|
+
expect(activeOverlays.length).to.equal(2);
|
|
764
643
|
opened = oneEvent(childMenu2, "sp-opened");
|
|
765
644
|
childMenu2.dispatchEvent(
|
|
766
645
|
new PointerEvent("pointerenter", { bubbles: true })
|
|
767
646
|
);
|
|
768
647
|
await opened;
|
|
648
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
649
|
+
expect(activeOverlays.length).to.equal(3);
|
|
769
650
|
const closed = Promise.all([
|
|
770
651
|
oneEvent(childMenu2, "sp-closed"),
|
|
771
652
|
oneEvent(rootMenu1, "sp-closed"),
|
|
772
653
|
oneEvent(el, "sp-closed")
|
|
773
654
|
]);
|
|
774
|
-
|
|
775
|
-
steps: [
|
|
776
|
-
{
|
|
777
|
-
type: "click",
|
|
778
|
-
position: [600, 5]
|
|
779
|
-
}
|
|
780
|
-
]
|
|
781
|
-
});
|
|
655
|
+
document.body.click();
|
|
782
656
|
await closed;
|
|
657
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
658
|
+
expect(activeOverlays.length).to.equal(0);
|
|
783
659
|
});
|
|
784
660
|
it("closes decendent menus when Menu Item in ancestor without a submenu is pointerentered", async () => {
|
|
785
661
|
const el = await styledFixture(html`
|
|
@@ -818,16 +694,22 @@ describe("Submenu", () => {
|
|
|
818
694
|
el.click();
|
|
819
695
|
await opened;
|
|
820
696
|
expect(el.open).to.be.true;
|
|
697
|
+
let activeOverlays = document.querySelectorAll("active-overlay");
|
|
698
|
+
expect(activeOverlays.length).to.equal(1);
|
|
821
699
|
opened = oneEvent(rootMenu, "sp-opened");
|
|
822
700
|
rootMenu.dispatchEvent(
|
|
823
701
|
new PointerEvent("pointerenter", { bubbles: true })
|
|
824
702
|
);
|
|
825
703
|
await opened;
|
|
704
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
705
|
+
expect(activeOverlays.length).to.equal(2);
|
|
826
706
|
const closed = oneEvent(rootMenu, "sp-closed");
|
|
827
707
|
noSubmenu.dispatchEvent(
|
|
828
708
|
new PointerEvent("pointerenter", { bubbles: true })
|
|
829
709
|
);
|
|
830
710
|
await closed;
|
|
711
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
712
|
+
expect(activeOverlays.length).to.equal(1);
|
|
831
713
|
});
|
|
832
714
|
it("closes decendent menus when Menu Item in ancestor is clicked", async () => {
|
|
833
715
|
const el = await styledFixture(html`
|
|
@@ -871,7 +753,6 @@ describe("Submenu", () => {
|
|
|
871
753
|
</sp-menu-group>
|
|
872
754
|
</sp-action-menu>
|
|
873
755
|
`);
|
|
874
|
-
await nextFrame();
|
|
875
756
|
const rootMenu1 = el.querySelector("#submenu-item-1");
|
|
876
757
|
const childMenu2 = el.querySelector("#submenu-item-2");
|
|
877
758
|
const ancestorItem = el.querySelector("#ancestor-item");
|
|
@@ -880,39 +761,33 @@ describe("Submenu", () => {
|
|
|
880
761
|
el.click();
|
|
881
762
|
await opened;
|
|
882
763
|
expect(el.open).to.be.true;
|
|
764
|
+
let activeOverlays = document.querySelectorAll("active-overlay");
|
|
765
|
+
expect(activeOverlays.length).to.equal(1);
|
|
883
766
|
opened = oneEvent(rootMenu1, "sp-opened");
|
|
884
767
|
rootMenu1.dispatchEvent(
|
|
885
768
|
new PointerEvent("pointerenter", { bubbles: true })
|
|
886
769
|
);
|
|
887
770
|
await opened;
|
|
771
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
772
|
+
expect(activeOverlays.length).to.equal(2);
|
|
888
773
|
opened = oneEvent(childMenu2, "sp-opened");
|
|
889
774
|
childMenu2.dispatchEvent(
|
|
890
775
|
new PointerEvent("pointerenter", { bubbles: true })
|
|
891
776
|
);
|
|
892
777
|
await opened;
|
|
778
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
779
|
+
expect(activeOverlays.length).to.equal(3);
|
|
893
780
|
const closed = Promise.all([
|
|
894
781
|
oneEvent(childMenu2, "sp-closed"),
|
|
895
782
|
oneEvent(rootMenu1, "sp-closed"),
|
|
896
783
|
oneEvent(el, "sp-closed")
|
|
897
784
|
]);
|
|
898
|
-
|
|
899
|
-
await sendMouse({
|
|
900
|
-
steps: [
|
|
901
|
-
{
|
|
902
|
-
type: "click",
|
|
903
|
-
position: [
|
|
904
|
-
rect.left + rect.width / 2,
|
|
905
|
-
rect.top + rect.height / 2
|
|
906
|
-
]
|
|
907
|
-
}
|
|
908
|
-
]
|
|
909
|
-
});
|
|
785
|
+
ancestorItem.click();
|
|
910
786
|
await closed;
|
|
787
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
788
|
+
expect(activeOverlays.length).to.equal(0);
|
|
911
789
|
});
|
|
912
790
|
it('cleans up submenus that close before they are "open"', async () => {
|
|
913
|
-
if ("showPopover" in document.createElement("div")) {
|
|
914
|
-
return;
|
|
915
|
-
}
|
|
916
791
|
await sendMouse({
|
|
917
792
|
steps: [
|
|
918
793
|
{
|
|
@@ -962,6 +837,7 @@ describe("Submenu", () => {
|
|
|
962
837
|
expect(rootItem2.open, "initially closed 2").to.be.false;
|
|
963
838
|
const rootItemBoundingRect1 = rootItem1.getBoundingClientRect();
|
|
964
839
|
const rootItemBoundingRect2 = rootItem2.getBoundingClientRect();
|
|
840
|
+
let activeOverlay;
|
|
965
841
|
await sendMouse({
|
|
966
842
|
steps: [
|
|
967
843
|
{
|
|
@@ -1006,12 +882,6 @@ describe("Submenu", () => {
|
|
|
1006
882
|
}
|
|
1007
883
|
]
|
|
1008
884
|
});
|
|
1009
|
-
await nextFrame();
|
|
1010
|
-
await nextFrame();
|
|
1011
|
-
await nextFrame();
|
|
1012
|
-
await nextFrame();
|
|
1013
|
-
await nextFrame();
|
|
1014
|
-
await nextFrame();
|
|
1015
885
|
const closed = oneEvent(rootItem2, "sp-closed");
|
|
1016
886
|
await sendMouse({
|
|
1017
887
|
steps: [
|
|
@@ -1019,12 +889,20 @@ describe("Submenu", () => {
|
|
|
1019
889
|
type: "move",
|
|
1020
890
|
position: [
|
|
1021
891
|
rootItemBoundingRect2.left + rootItemBoundingRect2.width / 2,
|
|
1022
|
-
rootItemBoundingRect2.top + rootItemBoundingRect2.height
|
|
892
|
+
rootItemBoundingRect2.top + rootItemBoundingRect2.top + rootItemBoundingRect2.height / 2
|
|
1023
893
|
]
|
|
1024
894
|
}
|
|
1025
895
|
]
|
|
1026
896
|
});
|
|
897
|
+
activeOverlay = document.querySelector(
|
|
898
|
+
"active-overlay"
|
|
899
|
+
);
|
|
900
|
+
expect(activeOverlay).to.not.be.null;
|
|
1027
901
|
await closed;
|
|
902
|
+
activeOverlay = document.querySelector(
|
|
903
|
+
"active-overlay"
|
|
904
|
+
);
|
|
905
|
+
expect(activeOverlay).to.be.null;
|
|
1028
906
|
expect(rootItem1.open, "finally closed 1").to.be.false;
|
|
1029
907
|
expect(rootItem2.open, "finally closed 2").to.be.false;
|
|
1030
908
|
});
|