Skip to content
This repository has been archived by the owner on Nov 27, 2022. It is now read-only.

Commit

Permalink
fix: update currentIndexRef when tab is switched by clicking tab bar (#…
Browse files Browse the repository at this point in the history
…1232)

There's a minor bug in web version of tabview. `currentIndexRef` in Pager.tsx file is only updated when tabs are switched using gesture. When they are switched using tab bar, you can not navigate back to tab which was mounted first.

Steps to reproduce:
Create a tabview with 3 tabs. Let say initial navigationState is { index: 0, title: 'abc' }. 
Now switch to any of the other 2 tabs
Now try to switch to 1st tab . It won't switch

Please note that gesture is not being used. `navigationState` is being updated and passed to TabView. In case of gesture it works correctly.


Co-authored-by: Kevin <kavin.patel@sprinklr.com>
Co-authored-by: Satyajit Sahoo <satyajit.happy@gmail.com>
  • Loading branch information
3 people authored Jul 30, 2021
1 parent e5d5cf6 commit 6347544
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/Pager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export default function Pager<T extends Route>({
}

if (layout.width && currentIndexRef.current !== index) {
currentIndexRef.current = index;
jumpToIndex(index);
}
}, [jumpToIndex, keyboardDismissMode, layout.width, index]);
Expand Down

0 comments on commit 6347544

Please sign in to comment.