@@ -10,7 +10,6 @@ import {
1010 shadow ,
1111} from '../../theme/tokens/sys/elevation' ;
1212import FAB from '../FAB' ;
13- import Shell from '../FAB/Shell' ;
1413
1514afterEach ( ( ) => {
1615 jest . restoreAllMocks ( ) ;
@@ -150,20 +149,12 @@ it.each(['icon', 'extended'] as const)(
150149 }
151150) ;
152151
153- it ( 'keeps an explicit shell elevation of zero on hover' , async ( ) => {
154- jest . replaceProperty ( Platform , 'OS' , 'web' ) ;
155- await render ( < Shell icon = "plus" onPress = { ( ) => { } } elevation = { 0 } /> ) ;
156- await fireEvent ( screen . getByTestId ( 'fab-shell' ) , 'hoverIn' ) ;
157- const [ flatShadow ] = shadow ( 0 , getTheme ( ) . colors . shadow ) ;
158- expect ( screen . getByTestId ( 'fab-shell-container' ) ) . toHaveStyle ( flatShadow ) ;
159- } ) ;
160-
161152it ( 'does not enable a FAB without an action when adding interaction handlers' , async ( ) => {
162153 await render ( < FAB icon = "plus" aria-label = "Create" /> ) ;
163154 expect ( screen . getByRole ( 'button' , { name : 'Create' } ) ) . toBeDisabled ( ) ;
164155} ) ;
165156
166- it ( 'hides an invisible FAB from accessibility and disables its action ' , async ( ) => {
157+ it ( 'hides an invisible FAB from accessibility and keyboard navigation without marking it disabled ' , async ( ) => {
167158 const onPress = jest . fn ( ) ;
168159 await render (
169160 < FAB icon = "plus" aria-label = "Create" onPress = { onPress } visible = { false } />
@@ -172,7 +163,10 @@ it('hides an invisible FAB from accessibility and disables its action', async ()
172163 const fab = screen . getByTestId ( 'floating-action-button' , {
173164 includeHiddenElements : true ,
174165 } ) ;
175- expect ( fab ) . toBeDisabled ( ) ;
166+ expect ( fab ) . not . toBeDisabled ( ) ;
167+ expect ( fab ) . toHaveProp ( 'accessible' , false ) ;
168+ expect ( fab ) . toHaveProp ( 'focusable' , false ) ;
169+ expect ( fab ) . toHaveProp ( 'tabIndex' , - 1 ) ;
176170 await userEvent . press ( fab ) ;
177171 expect ( onPress ) . not . toHaveBeenCalled ( ) ;
178172} ) ;
@@ -190,7 +184,7 @@ it('clears interaction elevation when a FAB is hidden and shown again', async ()
190184 ) ;
191185} ) ;
192186
193- it ( 'keeps the menu trigger at its existing elevation on web ' , async ( ) => {
187+ it ( 'uses the shared FAB hover elevation for the menu trigger ' , async ( ) => {
194188 jest . replaceProperty ( Platform , 'OS' , 'web' ) ;
195189 await render (
196190 < FAB . Menu
@@ -204,22 +198,40 @@ it('keeps the menu trigger at its existing elevation on web', async () => {
204198 />
205199 ) ;
206200 await fireEvent ( screen . getByTestId ( 'fab-shell' ) , 'hoverIn' ) ;
207- const [ restingShadow ] = shadow ( 3 , getTheme ( ) . colors . shadow ) ;
208- expect ( screen . getByTestId ( 'fab-shell-container' ) ) . toHaveStyle ( restingShadow ) ;
201+ const [ hoverShadow ] = shadow ( 4 , getTheme ( ) . colors . shadow ) ;
202+ expect ( screen . getByTestId ( 'fab-shell-container' ) ) . toHaveStyle ( hoverShadow ) ;
209203} ) ;
210204
211205it . each ( [ 'ios' , 'android' ] as const ) (
212- 'keeps native elevation unchanged on hover on %s' ,
206+ 'applies hover elevation alongside focus and restores it after press on %s' ,
213207 async ( platform ) => {
214208 jest . replaceProperty ( Platform , 'OS' , platform ) ;
215209 await render ( < FAB icon = "plus" onPress = { ( ) => { } } /> ) ;
216- await fireEvent ( screen . getByTestId ( 'floating-action-button' ) , 'hoverIn' ) ;
210+ const fab = screen . getByTestId ( 'floating-action-button' ) ;
211+ const container = screen . getByTestId ( 'floating-action-button-container' ) ;
217212 const [ restingShadow ] = shadow ( 3 , getTheme ( ) . colors . shadow ) ;
218- expect ( screen . getByTestId ( 'floating-action-button-container' ) ) . toHaveStyle (
213+ const [ hoverShadow ] = shadow ( 4 , getTheme ( ) . colors . shadow ) ;
214+ const restingStyle =
219215 platform === 'android'
220216 ? { elevation : androidElevationLevels [ 3 ] }
221- : restingShadow
222- ) ;
217+ : restingShadow ;
218+ const hoverStyle =
219+ platform === 'android'
220+ ? { elevation : androidElevationLevels [ 4 ] }
221+ : hoverShadow ;
222+
223+ await fireEvent ( fab , 'focus' , { nativeEvent : { } } ) ;
224+ expect ( container ) . toHaveStyle ( restingStyle ) ;
225+ await fireEvent ( fab , 'hoverIn' ) ;
226+ expect ( container ) . toHaveStyle ( hoverStyle ) ;
227+ await fireEvent ( fab , 'focus' , { nativeEvent : { } } ) ;
228+ expect ( container ) . toHaveStyle ( hoverStyle ) ;
229+ await fireEvent ( fab , 'pressIn' ) ;
230+ expect ( container ) . toHaveStyle ( restingStyle ) ;
231+ await fireEvent ( fab , 'pressOut' ) ;
232+ expect ( container ) . toHaveStyle ( hoverStyle ) ;
233+ await fireEvent ( fab , 'hoverOut' ) ;
234+ expect ( container ) . toHaveStyle ( restingStyle ) ;
223235 }
224236) ;
225237
0 commit comments