@spectrum-web-components/menu 0.16.18-overlay.17 → 0.30.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 +2155 -0
- package/package.json +11 -11
- package/sp-menu-divider.dev.js +2 -1
- package/sp-menu-divider.dev.js.map +2 -2
- package/sp-menu-divider.js +1 -1
- package/sp-menu-divider.js.map +3 -3
- package/sp-menu-group.dev.js +2 -1
- package/sp-menu-group.dev.js.map +2 -2
- package/sp-menu-group.js +1 -1
- package/sp-menu-group.js.map +3 -3
- package/sp-menu-item.dev.js +2 -1
- package/sp-menu-item.dev.js.map +2 -2
- package/sp-menu-item.js +1 -1
- package/sp-menu-item.js.map +3 -3
- package/sp-menu.dev.js +2 -1
- package/sp-menu.dev.js.map +2 -2
- package/sp-menu.js +1 -1
- package/sp-menu.js.map +3 -3
- package/src/Menu.d.ts +3 -11
- package/src/Menu.dev.js +60 -138
- package/src/Menu.dev.js.map +2 -2
- package/src/Menu.js +3 -6
- package/src/Menu.js.map +3 -3
- package/src/MenuGroup.dev.js +3 -1
- package/src/MenuGroup.dev.js.map +2 -2
- package/src/MenuGroup.js +5 -3
- package/src/MenuGroup.js.map +2 -2
- package/src/MenuItem.d.ts +4 -15
- package/src/MenuItem.dev.js +87 -95
- package/src/MenuItem.dev.js.map +3 -3
- package/src/MenuItem.js +12 -31
- package/src/MenuItem.js.map +3 -3
- package/src/menu-item.css.dev.js +2 -2
- package/src/menu-item.css.dev.js.map +1 -1
- package/src/menu-item.css.js +2 -2
- package/src/menu-item.css.js.map +1 -1
- package/src/menu.css.dev.js +1 -1
- package/src/menu.css.dev.js.map +1 -1
- package/src/menu.css.js +1 -1
- package/src/menu.css.js.map +1 -1
- package/src/spectrum-menu-item.css.dev.js +1 -1
- package/src/spectrum-menu-item.css.dev.js.map +1 -1
- package/src/spectrum-menu-item.css.js +1 -1
- package/src/spectrum-menu-item.css.js.map +1 -1
- package/stories/submenu.stories.js +20 -26
- 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-selects.test.js +1 -3
- package/test/menu-selects.test.js.map +2 -2
- package/test/menu.test.js +0 -7
- package/test/menu.test.js.map +2 -2
- package/test/submenu.test.js +69 -202
- 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,10 +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
149
|
expect(rootItem.open).to.be.false;
|
|
182
|
-
|
|
150
|
+
const opened = oneEvent(rootItem, "sp-opened");
|
|
183
151
|
sendMouse({
|
|
184
152
|
steps: [
|
|
185
153
|
{
|
|
@@ -195,7 +163,7 @@ describe("Submenu", () => {
|
|
|
195
163
|
expect(rootItem.open).to.be.true;
|
|
196
164
|
const item2 = document.querySelector(".submenu-item-2");
|
|
197
165
|
const item2BoundingRect = item2.getBoundingClientRect();
|
|
198
|
-
|
|
166
|
+
let closed = oneEvent(item2, "sp-opened");
|
|
199
167
|
sendMouse({
|
|
200
168
|
steps: [
|
|
201
169
|
{
|
|
@@ -207,11 +175,12 @@ describe("Submenu", () => {
|
|
|
207
175
|
}
|
|
208
176
|
]
|
|
209
177
|
});
|
|
210
|
-
await
|
|
178
|
+
await closed;
|
|
179
|
+
await nextFrame();
|
|
211
180
|
expect(item2.open).to.be.true;
|
|
212
181
|
const itemC = document.querySelector(".sub-submenu-item-3");
|
|
213
182
|
const itemCBoundingRect = itemC.getBoundingClientRect();
|
|
214
|
-
|
|
183
|
+
closed = oneEvent(rootItem, "sp-closed");
|
|
215
184
|
sendMouse({
|
|
216
185
|
steps: [
|
|
217
186
|
{
|
|
@@ -224,9 +193,10 @@ describe("Submenu", () => {
|
|
|
224
193
|
]
|
|
225
194
|
});
|
|
226
195
|
await closed;
|
|
196
|
+
await nextFrame();
|
|
197
|
+
expect(rootChanged.calledWith("Has submenu"), "root changed").to.be.true;
|
|
227
198
|
expect(submenuChanged.calledWith("Two"), "submenu changed").to.be.true;
|
|
228
199
|
expect(subSubmenuChanged.calledWith("C"), "sub submenu changed").to.be.true;
|
|
229
|
-
expect(rootChanged.calledWith("Has submenu"), "root changed").to.be.true;
|
|
230
200
|
});
|
|
231
201
|
[
|
|
232
202
|
{
|
|
@@ -241,13 +211,11 @@ describe("Submenu", () => {
|
|
|
241
211
|
}
|
|
242
212
|
].map((testData) => {
|
|
243
213
|
it(`selects - keyboard: ${testData.dir}`, async () => {
|
|
244
|
-
var _a, _b;
|
|
245
214
|
const rootChanged = spy();
|
|
246
215
|
const submenuChanged = spy();
|
|
247
216
|
const el = await styledFixture(
|
|
248
217
|
html`
|
|
249
218
|
<sp-menu
|
|
250
|
-
id="base"
|
|
251
219
|
@change=${(event) => {
|
|
252
220
|
rootChanged(event.target.value);
|
|
253
221
|
}}
|
|
@@ -255,7 +223,6 @@ describe("Submenu", () => {
|
|
|
255
223
|
<sp-menu-item class="root">
|
|
256
224
|
Has submenu
|
|
257
225
|
<sp-menu
|
|
258
|
-
id="sub"
|
|
259
226
|
slot="submenu"
|
|
260
227
|
@change=${(event) => {
|
|
261
228
|
submenuChanged(event.target.value);
|
|
@@ -278,7 +245,6 @@ describe("Submenu", () => {
|
|
|
278
245
|
);
|
|
279
246
|
await elementUpdated(el);
|
|
280
247
|
const rootItem = el.querySelector(".root");
|
|
281
|
-
const submenu = el.querySelector('[slot="submenu"]');
|
|
282
248
|
expect(rootItem.open).to.be.false;
|
|
283
249
|
el.focus();
|
|
284
250
|
await elementUpdated(el);
|
|
@@ -288,20 +254,12 @@ describe("Submenu", () => {
|
|
|
288
254
|
});
|
|
289
255
|
await opened;
|
|
290
256
|
expect(rootItem.open).to.be.true;
|
|
291
|
-
expect(
|
|
292
|
-
submenu === document.activeElement,
|
|
293
|
-
`${(_a = document.activeElement) == null ? void 0 : _a.id}`
|
|
294
|
-
).to.be.true;
|
|
295
257
|
let closed = oneEvent(rootItem, "sp-closed");
|
|
296
258
|
sendKeys({
|
|
297
259
|
press: testData.closeKey
|
|
298
260
|
});
|
|
299
261
|
await closed;
|
|
300
262
|
expect(rootItem.open).to.be.false;
|
|
301
|
-
expect(
|
|
302
|
-
el === document.activeElement,
|
|
303
|
-
`${(_b = document.activeElement) == null ? void 0 : _b.id}`
|
|
304
|
-
).to.be.true;
|
|
305
263
|
opened = oneEvent(rootItem, "sp-opened");
|
|
306
264
|
sendKeys({
|
|
307
265
|
press: testData.openKey
|
|
@@ -316,12 +274,8 @@ describe("Submenu", () => {
|
|
|
316
274
|
press: "Enter"
|
|
317
275
|
});
|
|
318
276
|
await closed;
|
|
277
|
+
expect(rootChanged.calledWith("Has submenu"), "root changed").to.be.true;
|
|
319
278
|
expect(submenuChanged.calledWith("Two"), "submenu changed").to.be.true;
|
|
320
|
-
expect(rootChanged.called, "root has changed").to.be.true;
|
|
321
|
-
expect(
|
|
322
|
-
rootChanged.calledWith("Has submenu"),
|
|
323
|
-
"root specifically changed"
|
|
324
|
-
).to.be.true;
|
|
325
279
|
});
|
|
326
280
|
});
|
|
327
281
|
it("closes on `pointerleave`", async () => {
|
|
@@ -453,8 +407,7 @@ describe("Submenu", () => {
|
|
|
453
407
|
});
|
|
454
408
|
await closed;
|
|
455
409
|
});
|
|
456
|
-
it("
|
|
457
|
-
const clickSpy = spy();
|
|
410
|
+
it("stays open when mousing between menu item and submenu", async () => {
|
|
458
411
|
const el = await styledFixture(
|
|
459
412
|
html`
|
|
460
413
|
<sp-menu>
|
|
@@ -464,10 +417,7 @@ describe("Submenu", () => {
|
|
|
464
417
|
<sp-menu-item class="submenu-item-1">
|
|
465
418
|
One
|
|
466
419
|
</sp-menu-item>
|
|
467
|
-
<sp-menu-item
|
|
468
|
-
class="submenu-item-2"
|
|
469
|
-
@click=${() => clickSpy()}
|
|
470
|
-
>
|
|
420
|
+
<sp-menu-item class="submenu-item-2">
|
|
471
421
|
Two
|
|
472
422
|
</sp-menu-item>
|
|
473
423
|
<sp-menu-item class="submenu-item-3">
|
|
@@ -480,7 +430,6 @@ describe("Submenu", () => {
|
|
|
480
430
|
);
|
|
481
431
|
await elementUpdated(el);
|
|
482
432
|
const rootItem = el.querySelector(".root");
|
|
483
|
-
const subItem = el.querySelector(".submenu-item-2");
|
|
484
433
|
const rootItemBoundingRect = rootItem.getBoundingClientRect();
|
|
485
434
|
expect(rootItem.open).to.be.false;
|
|
486
435
|
const opened = oneEvent(rootItem, "sp-opened");
|
|
@@ -495,114 +444,30 @@ describe("Submenu", () => {
|
|
|
495
444
|
}
|
|
496
445
|
]
|
|
497
446
|
});
|
|
498
|
-
await nextFrame();
|
|
499
|
-
await nextFrame();
|
|
500
|
-
const subItemBoundingRect = subItem.getBoundingClientRect();
|
|
501
447
|
await sendMouse({
|
|
502
448
|
steps: [
|
|
503
449
|
{
|
|
504
450
|
type: "move",
|
|
505
451
|
position: [
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
]
|
|
509
|
-
}
|
|
510
|
-
]
|
|
511
|
-
});
|
|
512
|
-
await opened;
|
|
513
|
-
expect(rootItem.open).to.be.true;
|
|
514
|
-
await aTimeout(150);
|
|
515
|
-
expect(rootItem.open).to.be.true;
|
|
516
|
-
const closed = oneEvent(rootItem, "sp-closed");
|
|
517
|
-
sendMouse({
|
|
518
|
-
steps: [
|
|
519
|
-
{
|
|
520
|
-
type: "click",
|
|
521
|
-
position: [
|
|
522
|
-
subItemBoundingRect.left + subItemBoundingRect.width / 2,
|
|
523
|
-
subItemBoundingRect.top + subItemBoundingRect.height / 2
|
|
452
|
+
rootItemBoundingRect.left + rootItemBoundingRect.width / 2,
|
|
453
|
+
rootItemBoundingRect.top + rootItemBoundingRect.height * 2
|
|
524
454
|
]
|
|
525
455
|
}
|
|
526
456
|
]
|
|
527
457
|
});
|
|
528
|
-
await closed;
|
|
529
|
-
expect(clickSpy.callCount).to.equal(1);
|
|
530
|
-
});
|
|
531
|
-
it("stays open when mousing between menu item and submenu", async () => {
|
|
532
|
-
const clickSpy = spy();
|
|
533
|
-
const el = await styledFixture(
|
|
534
|
-
html`
|
|
535
|
-
<sp-menu>
|
|
536
|
-
<sp-menu-item class="root">
|
|
537
|
-
Has submenu
|
|
538
|
-
<sp-menu slot="submenu">
|
|
539
|
-
<sp-menu-item class="submenu-item-1">
|
|
540
|
-
One
|
|
541
|
-
</sp-menu-item>
|
|
542
|
-
<sp-menu-item
|
|
543
|
-
class="submenu-item-2"
|
|
544
|
-
@click=${() => clickSpy()}
|
|
545
|
-
>
|
|
546
|
-
Two
|
|
547
|
-
</sp-menu-item>
|
|
548
|
-
<sp-menu-item class="submenu-item-3">
|
|
549
|
-
Three
|
|
550
|
-
</sp-menu-item>
|
|
551
|
-
</sp-menu>
|
|
552
|
-
</sp-menu-item>
|
|
553
|
-
</sp-menu>
|
|
554
|
-
`
|
|
555
|
-
);
|
|
556
|
-
await elementUpdated(el);
|
|
557
|
-
const rootItem = el.querySelector(".root");
|
|
558
|
-
const subItem = el.querySelector(".submenu-item-2");
|
|
559
|
-
const rootItemBoundingRect = rootItem.getBoundingClientRect();
|
|
560
|
-
expect(rootItem.open).to.be.false;
|
|
561
|
-
const opened = oneEvent(rootItem, "sp-opened");
|
|
562
458
|
await sendMouse({
|
|
563
459
|
steps: [
|
|
564
460
|
{
|
|
565
461
|
type: "move",
|
|
566
462
|
position: [
|
|
567
|
-
rootItemBoundingRect.left + rootItemBoundingRect.width
|
|
463
|
+
rootItemBoundingRect.left + rootItemBoundingRect.width * 1.5,
|
|
568
464
|
rootItemBoundingRect.top + rootItemBoundingRect.height / 2
|
|
569
465
|
]
|
|
570
466
|
}
|
|
571
467
|
]
|
|
572
468
|
});
|
|
573
469
|
await opened;
|
|
574
|
-
await nextFrame();
|
|
575
|
-
await nextFrame();
|
|
576
|
-
const subItemBoundingRect = subItem.getBoundingClientRect();
|
|
577
470
|
expect(rootItem.open).to.be.true;
|
|
578
|
-
await sendMouse({
|
|
579
|
-
steps: [
|
|
580
|
-
{
|
|
581
|
-
type: "move",
|
|
582
|
-
position: [
|
|
583
|
-
subItemBoundingRect.left + subItemBoundingRect.width / 2,
|
|
584
|
-
subItemBoundingRect.top + subItemBoundingRect.height / 2
|
|
585
|
-
]
|
|
586
|
-
}
|
|
587
|
-
]
|
|
588
|
-
});
|
|
589
|
-
expect(rootItem.open).to.be.true;
|
|
590
|
-
await aTimeout(150);
|
|
591
|
-
expect(rootItem.open).to.be.true;
|
|
592
|
-
const closed = oneEvent(rootItem, "sp-closed");
|
|
593
|
-
sendMouse({
|
|
594
|
-
steps: [
|
|
595
|
-
{
|
|
596
|
-
type: "click",
|
|
597
|
-
position: [
|
|
598
|
-
subItemBoundingRect.left + subItemBoundingRect.width / 2,
|
|
599
|
-
subItemBoundingRect.top + subItemBoundingRect.height / 2
|
|
600
|
-
]
|
|
601
|
-
}
|
|
602
|
-
]
|
|
603
|
-
});
|
|
604
|
-
await closed;
|
|
605
|
-
expect(clickSpy.callCount).to.equal(1);
|
|
606
471
|
});
|
|
607
472
|
it("not opens if disabled", async () => {
|
|
608
473
|
const el = await styledFixture(
|
|
@@ -691,34 +556,33 @@ describe("Submenu", () => {
|
|
|
691
556
|
el.click();
|
|
692
557
|
await opened;
|
|
693
558
|
expect(el.open).to.be.true;
|
|
559
|
+
let activeOverlays = document.querySelectorAll("active-overlay");
|
|
560
|
+
expect(activeOverlays.length).to.equal(1);
|
|
694
561
|
opened = oneEvent(rootMenu1, "sp-opened");
|
|
695
562
|
rootMenu1.dispatchEvent(
|
|
696
563
|
new PointerEvent("pointerenter", { bubbles: true })
|
|
697
564
|
);
|
|
698
565
|
await opened;
|
|
566
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
567
|
+
expect(activeOverlays.length).to.equal(2);
|
|
699
568
|
opened = oneEvent(childMenu2, "sp-opened");
|
|
700
569
|
childMenu2.dispatchEvent(
|
|
701
570
|
new PointerEvent("pointerenter", { bubbles: true })
|
|
702
571
|
);
|
|
703
572
|
await opened;
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
const
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
]
|
|
718
|
-
});
|
|
719
|
-
await childMenu2Closed;
|
|
720
|
-
await rootMenu1Closed;
|
|
721
|
-
await rootMenu2Closed;
|
|
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
|
+
]);
|
|
580
|
+
rootMenu2.dispatchEvent(
|
|
581
|
+
new PointerEvent("pointerenter", { bubbles: true })
|
|
582
|
+
);
|
|
583
|
+
await overlaysManaged;
|
|
584
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
585
|
+
expect(activeOverlays.length).to.equal(2);
|
|
722
586
|
});
|
|
723
587
|
it("closes back to the first overlay without a `root` when clicking away", async () => {
|
|
724
588
|
const el = await styledFixture(html`
|
|
@@ -767,30 +631,31 @@ describe("Submenu", () => {
|
|
|
767
631
|
el.click();
|
|
768
632
|
await opened;
|
|
769
633
|
expect(el.open).to.be.true;
|
|
634
|
+
let activeOverlays = document.querySelectorAll("active-overlay");
|
|
635
|
+
expect(activeOverlays.length).to.equal(1);
|
|
770
636
|
opened = oneEvent(rootMenu1, "sp-opened");
|
|
771
637
|
rootMenu1.dispatchEvent(
|
|
772
638
|
new PointerEvent("pointerenter", { bubbles: true })
|
|
773
639
|
);
|
|
774
640
|
await opened;
|
|
641
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
642
|
+
expect(activeOverlays.length).to.equal(2);
|
|
775
643
|
opened = oneEvent(childMenu2, "sp-opened");
|
|
776
644
|
childMenu2.dispatchEvent(
|
|
777
645
|
new PointerEvent("pointerenter", { bubbles: true })
|
|
778
646
|
);
|
|
779
647
|
await opened;
|
|
648
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
649
|
+
expect(activeOverlays.length).to.equal(3);
|
|
780
650
|
const closed = Promise.all([
|
|
781
651
|
oneEvent(childMenu2, "sp-closed"),
|
|
782
652
|
oneEvent(rootMenu1, "sp-closed"),
|
|
783
653
|
oneEvent(el, "sp-closed")
|
|
784
654
|
]);
|
|
785
|
-
|
|
786
|
-
steps: [
|
|
787
|
-
{
|
|
788
|
-
type: "click",
|
|
789
|
-
position: [600, 5]
|
|
790
|
-
}
|
|
791
|
-
]
|
|
792
|
-
});
|
|
655
|
+
document.body.click();
|
|
793
656
|
await closed;
|
|
657
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
658
|
+
expect(activeOverlays.length).to.equal(0);
|
|
794
659
|
});
|
|
795
660
|
it("closes decendent menus when Menu Item in ancestor without a submenu is pointerentered", async () => {
|
|
796
661
|
const el = await styledFixture(html`
|
|
@@ -829,16 +694,22 @@ describe("Submenu", () => {
|
|
|
829
694
|
el.click();
|
|
830
695
|
await opened;
|
|
831
696
|
expect(el.open).to.be.true;
|
|
697
|
+
let activeOverlays = document.querySelectorAll("active-overlay");
|
|
698
|
+
expect(activeOverlays.length).to.equal(1);
|
|
832
699
|
opened = oneEvent(rootMenu, "sp-opened");
|
|
833
700
|
rootMenu.dispatchEvent(
|
|
834
701
|
new PointerEvent("pointerenter", { bubbles: true })
|
|
835
702
|
);
|
|
836
703
|
await opened;
|
|
704
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
705
|
+
expect(activeOverlays.length).to.equal(2);
|
|
837
706
|
const closed = oneEvent(rootMenu, "sp-closed");
|
|
838
707
|
noSubmenu.dispatchEvent(
|
|
839
708
|
new PointerEvent("pointerenter", { bubbles: true })
|
|
840
709
|
);
|
|
841
710
|
await closed;
|
|
711
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
712
|
+
expect(activeOverlays.length).to.equal(1);
|
|
842
713
|
});
|
|
843
714
|
it("closes decendent menus when Menu Item in ancestor is clicked", async () => {
|
|
844
715
|
const el = await styledFixture(html`
|
|
@@ -882,7 +753,6 @@ describe("Submenu", () => {
|
|
|
882
753
|
</sp-menu-group>
|
|
883
754
|
</sp-action-menu>
|
|
884
755
|
`);
|
|
885
|
-
await nextFrame();
|
|
886
756
|
const rootMenu1 = el.querySelector("#submenu-item-1");
|
|
887
757
|
const childMenu2 = el.querySelector("#submenu-item-2");
|
|
888
758
|
const ancestorItem = el.querySelector("#ancestor-item");
|
|
@@ -891,39 +761,33 @@ describe("Submenu", () => {
|
|
|
891
761
|
el.click();
|
|
892
762
|
await opened;
|
|
893
763
|
expect(el.open).to.be.true;
|
|
764
|
+
let activeOverlays = document.querySelectorAll("active-overlay");
|
|
765
|
+
expect(activeOverlays.length).to.equal(1);
|
|
894
766
|
opened = oneEvent(rootMenu1, "sp-opened");
|
|
895
767
|
rootMenu1.dispatchEvent(
|
|
896
768
|
new PointerEvent("pointerenter", { bubbles: true })
|
|
897
769
|
);
|
|
898
770
|
await opened;
|
|
771
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
772
|
+
expect(activeOverlays.length).to.equal(2);
|
|
899
773
|
opened = oneEvent(childMenu2, "sp-opened");
|
|
900
774
|
childMenu2.dispatchEvent(
|
|
901
775
|
new PointerEvent("pointerenter", { bubbles: true })
|
|
902
776
|
);
|
|
903
777
|
await opened;
|
|
778
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
779
|
+
expect(activeOverlays.length).to.equal(3);
|
|
904
780
|
const closed = Promise.all([
|
|
905
781
|
oneEvent(childMenu2, "sp-closed"),
|
|
906
782
|
oneEvent(rootMenu1, "sp-closed"),
|
|
907
783
|
oneEvent(el, "sp-closed")
|
|
908
784
|
]);
|
|
909
|
-
|
|
910
|
-
await sendMouse({
|
|
911
|
-
steps: [
|
|
912
|
-
{
|
|
913
|
-
type: "click",
|
|
914
|
-
position: [
|
|
915
|
-
rect.left + rect.width / 2,
|
|
916
|
-
rect.top + rect.height / 2
|
|
917
|
-
]
|
|
918
|
-
}
|
|
919
|
-
]
|
|
920
|
-
});
|
|
785
|
+
ancestorItem.click();
|
|
921
786
|
await closed;
|
|
787
|
+
activeOverlays = document.querySelectorAll("active-overlay");
|
|
788
|
+
expect(activeOverlays.length).to.equal(0);
|
|
922
789
|
});
|
|
923
790
|
it('cleans up submenus that close before they are "open"', async () => {
|
|
924
|
-
if ("showPopover" in document.createElement("div")) {
|
|
925
|
-
return;
|
|
926
|
-
}
|
|
927
791
|
await sendMouse({
|
|
928
792
|
steps: [
|
|
929
793
|
{
|
|
@@ -973,6 +837,7 @@ describe("Submenu", () => {
|
|
|
973
837
|
expect(rootItem2.open, "initially closed 2").to.be.false;
|
|
974
838
|
const rootItemBoundingRect1 = rootItem1.getBoundingClientRect();
|
|
975
839
|
const rootItemBoundingRect2 = rootItem2.getBoundingClientRect();
|
|
840
|
+
let activeOverlay;
|
|
976
841
|
await sendMouse({
|
|
977
842
|
steps: [
|
|
978
843
|
{
|
|
@@ -1017,12 +882,6 @@ describe("Submenu", () => {
|
|
|
1017
882
|
}
|
|
1018
883
|
]
|
|
1019
884
|
});
|
|
1020
|
-
await nextFrame();
|
|
1021
|
-
await nextFrame();
|
|
1022
|
-
await nextFrame();
|
|
1023
|
-
await nextFrame();
|
|
1024
|
-
await nextFrame();
|
|
1025
|
-
await nextFrame();
|
|
1026
885
|
const closed = oneEvent(rootItem2, "sp-closed");
|
|
1027
886
|
await sendMouse({
|
|
1028
887
|
steps: [
|
|
@@ -1030,12 +889,20 @@ describe("Submenu", () => {
|
|
|
1030
889
|
type: "move",
|
|
1031
890
|
position: [
|
|
1032
891
|
rootItemBoundingRect2.left + rootItemBoundingRect2.width / 2,
|
|
1033
|
-
rootItemBoundingRect2.top + rootItemBoundingRect2.height
|
|
892
|
+
rootItemBoundingRect2.top + rootItemBoundingRect2.top + rootItemBoundingRect2.height / 2
|
|
1034
893
|
]
|
|
1035
894
|
}
|
|
1036
895
|
]
|
|
1037
896
|
});
|
|
897
|
+
activeOverlay = document.querySelector(
|
|
898
|
+
"active-overlay"
|
|
899
|
+
);
|
|
900
|
+
expect(activeOverlay).to.not.be.null;
|
|
1038
901
|
await closed;
|
|
902
|
+
activeOverlay = document.querySelector(
|
|
903
|
+
"active-overlay"
|
|
904
|
+
);
|
|
905
|
+
expect(activeOverlay).to.be.null;
|
|
1039
906
|
expect(rootItem1.open, "finally closed 1").to.be.false;
|
|
1040
907
|
expect(rootItem2.open, "finally closed 2").to.be.false;
|
|
1041
908
|
});
|