@@ -1500,6 +1500,7 @@ describe('Keyboard interactions', () => {
1500
1500
1501
1501
// Open the second popover
1502
1502
await click ( getByText ( 'Trigger 2' ) )
1503
+ getByText ( 'Trigger 2' ) ?. focus ( )
1503
1504
1504
1505
// Ensure the second popover is open
1505
1506
assertPopoverButton ( { state : PopoverState . Visible } , getByText ( 'Trigger 2' ) )
@@ -2146,6 +2147,7 @@ describe('Mouse interactions', () => {
2146
2147
2147
2148
// Open popover
2148
2149
await click ( getPopoverButton ( ) )
2150
+ getPopoverButton ( ) ?. focus ( )
2149
2151
2150
2152
// Verify it is open
2151
2153
assertPopoverButton ( { state : PopoverState . Visible } )
@@ -2269,4 +2271,62 @@ describe('Mouse interactions', () => {
2269
2271
assertPopoverButton ( { state : PopoverState . InvisibleHidden } )
2270
2272
} )
2271
2273
)
2274
+
2275
+ it (
2276
+ 'should be possible to close the Popover by clicking on the Popover.Button outside the Popover.Panel' ,
2277
+ suppressConsoleLogs ( async ( ) => {
2278
+ render (
2279
+ < Popover >
2280
+ < Popover . Button > Toggle</ Popover . Button >
2281
+ < Popover . Panel >
2282
+ < button > Contents</ button >
2283
+ </ Popover . Panel >
2284
+ </ Popover >
2285
+ )
2286
+
2287
+ // Open the popover
2288
+ await click ( getPopoverButton ( ) )
2289
+
2290
+ // Verify it is open
2291
+ assertPopoverPanel ( { state : PopoverState . Visible } )
2292
+
2293
+ // Close the popover
2294
+ await click ( getPopoverButton ( ) )
2295
+
2296
+ // Verify it is closed
2297
+ assertPopoverPanel ( { state : PopoverState . InvisibleUnmounted } )
2298
+
2299
+ // Verify the button is focused
2300
+ assertActiveElement ( getPopoverButton ( ) )
2301
+ } )
2302
+ )
2303
+
2304
+ it (
2305
+ 'should be possible to close the Popover by clicking on the Popover.Button outside the Popover.Panel (when using the `focus` prop)' ,
2306
+ suppressConsoleLogs ( async ( ) => {
2307
+ render (
2308
+ < Popover >
2309
+ < Popover . Button > Toggle</ Popover . Button >
2310
+ < Popover . Panel focus >
2311
+ < button > Contents</ button >
2312
+ </ Popover . Panel >
2313
+ </ Popover >
2314
+ )
2315
+
2316
+ // Open the popover
2317
+ await click ( getPopoverButton ( ) )
2318
+
2319
+ // Verify it is open
2320
+ assertPopoverPanel ( { state : PopoverState . Visible } )
2321
+
2322
+ // Close the popover
2323
+ await click ( getPopoverButton ( ) )
2324
+
2325
+ // Verify it is closed
2326
+ assertPopoverPanel ( { state : PopoverState . InvisibleUnmounted } )
2327
+
2328
+ // Verify the button is focused
2329
+ assertActiveElement ( getPopoverButton ( ) )
2330
+ } )
2331
+ )
2272
2332
} )
0 commit comments