@@ -380,6 +380,7 @@ const BottomNavigationBar = <Route extends BaseRoute>({
380380 * Animation for the background color ripple, used to determine it's scale and opacity.
381381 */
382382 const rippleAnim = useAnimatedValue ( MIN_RIPPLE_SCALE ) ;
383+ const targetIndexRef = React . useRef ( navigationState . index ) ;
383384
384385 /**
385386 * Layout of the navigation bar. The width is used to determine the size and position of the ripple.
@@ -412,6 +413,7 @@ const BottomNavigationBar = <Route extends BaseRoute>({
412413
413414 const animateToIndex = React . useCallback (
414415 ( index : number ) => {
416+ targetIndexRef . current = index ;
415417 // Reset the ripple to avoid glitch if it's currently animating
416418 rippleAnim . setValue ( MIN_RIPPLE_SCALE ) ;
417419
@@ -429,13 +431,37 @@ const BottomNavigationBar = <Route extends BaseRoute>({
429431 easing : animationEasing ,
430432 } )
431433 ) ,
432- ] ) . start ( ( ) => {
433- // Workaround a bug in native animations where this is reset after first animation
434- tabsAnims . map ( ( tab , i ) => tab . setValue ( i === index ? 1 : 0 ) ) ;
434+ ] ) . start ( ( result ) => {
435+ if ( targetIndexRef . current !== index ) {
436+ return ;
437+ }
438+
439+ // Explicitly finish animation state to avoid RN 0.80 drops leaving tabs half-focused
440+ tabsAnims . forEach ( ( tab , i ) => {
441+ tab . stopAnimation ( ) ;
442+ tab . setValue ( i === index ? 1 : 0 ) ;
443+ } ) ;
435444
436- // Update the index to change bar's background color and then hide the ripple
445+ indexAnim . stopAnimation ( ) ;
437446 indexAnim . setValue ( index ) ;
447+
448+ rippleAnim . stopAnimation ( ) ;
438449 rippleAnim . setValue ( MIN_RIPPLE_SCALE ) ;
450+
451+ if ( result ?. finished === false ) {
452+ requestAnimationFrame ( ( ) => {
453+ if ( targetIndexRef . current !== index ) {
454+ return ;
455+ }
456+
457+ tabsAnims . forEach ( ( tab , i ) => {
458+ tab . stopAnimation ( ) ;
459+ tab . setValue ( i === index ? 1 : 0 ) ;
460+ } ) ;
461+ indexAnim . setValue ( index ) ;
462+ rippleAnim . setValue ( MIN_RIPPLE_SCALE ) ;
463+ } ) ;
464+ }
439465 } ) ;
440466 } ,
441467 [
0 commit comments