@@ -1956,17 +1956,20 @@ describe('Keyboard interactions', () => {
1956
1956
1957
1957
describe ( '`Tab` key' , ( ) => {
1958
1958
it (
1959
- 'should focus trap when we use Tab' ,
1959
+ 'should not focus trap when we use Tab' ,
1960
1960
suppressConsoleLogs ( async ( ) => {
1961
1961
render (
1962
- < Listbox value = { undefined } onChange = { ( x ) => console . log ( x ) } >
1963
- < Listbox . Button > Trigger</ Listbox . Button >
1964
- < Listbox . Options >
1965
- < Listbox . Option value = "a" > Option A</ Listbox . Option >
1966
- < Listbox . Option value = "b" > Option B</ Listbox . Option >
1967
- < Listbox . Option value = "c" > Option C</ Listbox . Option >
1968
- </ Listbox . Options >
1969
- </ Listbox >
1962
+ < >
1963
+ < Listbox value = { undefined } onChange = { ( x ) => console . log ( x ) } >
1964
+ < Listbox . Button > Trigger</ Listbox . Button >
1965
+ < Listbox . Options >
1966
+ < Listbox . Option value = "a" > Option A</ Listbox . Option >
1967
+ < Listbox . Option value = "b" > Option B</ Listbox . Option >
1968
+ < Listbox . Option value = "c" > Option C</ Listbox . Option >
1969
+ </ Listbox . Options >
1970
+ </ Listbox >
1971
+ < a href = "#" > After</ a >
1972
+ </ >
1970
1973
)
1971
1974
1972
1975
assertListboxButton ( {
@@ -1996,28 +1999,31 @@ describe('Keyboard interactions', () => {
1996
1999
options . forEach ( ( option ) => assertListboxOption ( option ) )
1997
2000
assertActiveListboxOption ( options [ 0 ] )
1998
2001
1999
- // Try to tab
2002
+ // Tab to the next element
2000
2003
await press ( Keys . Tab )
2001
2004
2002
- // Verify it is still open
2003
- assertListboxButton ( { state : ListboxState . Visible } )
2004
- assertListbox ( { state : ListboxState . Visible } )
2005
- assertActiveElement ( getListbox ( ) )
2005
+ // Verify the listbox is closed
2006
+ assertListboxButton ( { state : ListboxState . InvisibleUnmounted } )
2007
+ assertListbox ( { state : ListboxState . InvisibleUnmounted } )
2008
+ assertActiveElement ( getByText ( 'After' ) )
2006
2009
} )
2007
2010
)
2008
2011
2009
2012
it (
2010
- 'should focus trap when we use Shift+Tab' ,
2013
+ 'should not focus trap when we use Shift+Tab' ,
2011
2014
suppressConsoleLogs ( async ( ) => {
2012
2015
render (
2013
- < Listbox value = { undefined } onChange = { ( x ) => console . log ( x ) } >
2014
- < Listbox . Button > Trigger</ Listbox . Button >
2015
- < Listbox . Options >
2016
- < Listbox . Option value = "a" > Option A</ Listbox . Option >
2017
- < Listbox . Option value = "b" > Option B</ Listbox . Option >
2018
- < Listbox . Option value = "c" > Option C</ Listbox . Option >
2019
- </ Listbox . Options >
2020
- </ Listbox >
2016
+ < >
2017
+ < a href = "#" > Before</ a >
2018
+ < Listbox value = { undefined } onChange = { ( x ) => console . log ( x ) } >
2019
+ < Listbox . Button > Trigger</ Listbox . Button >
2020
+ < Listbox . Options >
2021
+ < Listbox . Option value = "a" > Option A</ Listbox . Option >
2022
+ < Listbox . Option value = "b" > Option B</ Listbox . Option >
2023
+ < Listbox . Option value = "c" > Option C</ Listbox . Option >
2024
+ </ Listbox . Options >
2025
+ </ Listbox >
2026
+ </ >
2021
2027
)
2022
2028
2023
2029
assertListboxButton ( {
@@ -2050,10 +2056,10 @@ describe('Keyboard interactions', () => {
2050
2056
// Try to Shift+Tab
2051
2057
await press ( shift ( Keys . Tab ) )
2052
2058
2053
- // Verify it is still open
2054
- assertListboxButton ( { state : ListboxState . Visible } )
2055
- assertListbox ( { state : ListboxState . Visible } )
2056
- assertActiveElement ( getListbox ( ) )
2059
+ // Verify the listbox is closed
2060
+ assertListboxButton ( { state : ListboxState . InvisibleUnmounted } )
2061
+ assertListbox ( { state : ListboxState . InvisibleUnmounted } )
2062
+ assertActiveElement ( getByText ( 'Before' ) )
2057
2063
} )
2058
2064
)
2059
2065
} )
0 commit comments