@@ -15,6 +15,33 @@ const menuFixture = `
15
15
</fluent-menu>
16
16
` ;
17
17
18
+ const complexMenuFixture = `
19
+ <fluent-menu>
20
+ <fluent-menu-button appearance="primary" slot="trigger">Toggle Menu</fluent-menu-button>
21
+ <fluent-menu-list>
22
+ <fluent-menu-item>
23
+ Item 1
24
+ <fluent-menu-list slot="submenu">
25
+ <fluent-menu-item> Subitem 1 </fluent-menu-item>
26
+ <fluent-menu-item> Subitem 2 </fluent-menu-item>
27
+ </fluent-menu-list>
28
+ </fluent-menu-item>
29
+
30
+ <fluent-menu-item role="menuitemcheckbox"> Item 2 </fluent-menu-item>
31
+ <fluent-menu-item role="menuitemcheckbox"> Item 3 </fluent-menu-item>
32
+
33
+ <fluent-divider role="separator" aria-orientation="horizontal" orientation="horizontal"></fluent-divider>
34
+
35
+ <fluent-menu-item>Menu item 4</fluent-menu-item>
36
+ <fluent-menu-item>Menu item 5</fluent-menu-item>
37
+ <fluent-menu-item>Menu item 6</fluent-menu-item>
38
+
39
+ <fluent-menu-item>Menu item 7</fluent-menu-item>
40
+ <fluent-menu-item>Menu item 8</fluent-menu-item>
41
+ </fluent-menu-list>
42
+ </fluent-menu>
43
+ ` ;
44
+
18
45
test . describe ( 'Menu' , ( ) => {
19
46
let page : Page ;
20
47
let element : Locator ;
@@ -162,4 +189,27 @@ test.describe('Menu', () => {
162
189
await menuButton . dispatchEvent ( 'contextmenu' ) ;
163
190
await expect ( menuList ) . toBeVisible ( ) ;
164
191
} ) ;
192
+
193
+ test ( 'should focus first item after closing a submenu' , async ( ) => {
194
+ page . setContent ( complexMenuFixture ) ;
195
+
196
+ await menuButton . click ( ) ;
197
+
198
+ await expect ( menuList . first ( ) ) . toBeVisible ( ) ;
199
+ await expect ( menuList . last ( ) ) . toBeHidden ( ) ;
200
+
201
+ await menuItems . first ( ) . focus ( ) ;
202
+
203
+ await page . keyboard . press ( 'ArrowRight' ) ;
204
+
205
+ await expect ( menuList . last ( ) ) . toBeVisible ( ) ;
206
+
207
+ await page . keyboard . press ( 'ArrowLeft' ) ;
208
+
209
+ await expect ( menuList . last ( ) ) . toBeHidden ( ) ;
210
+
211
+ await expect ( menuList . first ( ) ) . toBeVisible ( ) ;
212
+
213
+ await expect ( menuItems . first ( ) ) . toBeFocused ( ) ;
214
+ } ) ;
165
215
} ) ;
0 commit comments