[Bug] Tabs index incorrect while set Orientation programmatically
See original GitHub issueIn my case, I have 4 tabs and Tab 2 (index 1) should be in landscape mode so I used the plugin react-native-orientation to do that. And after that, I saw the bug.
react-native, react and native-base version
“native-base”: “^2.4.5”, “react”: “16.0.0-alpha.12”, “react-native”: “0.48.4”, “react-native-orientation”: “^3.1.3”,
Expected behaviour
When Tab 2 is active (landscape) -> Click Tab 3 -> Tab 3 should be active (portrait)
Actual behaviour
Tab 4 is active (portrait)
Steps to reproduce (code snippet or screenshot)
`<Tabs locked={true} onChangeTab={({i, ref, from}) => { console.log("Tab index changed: ", index);
setTimeout(() => {
if(index == 1) {
Orientation.lockToLandscape();
}
else {
Orientation.lockToPortrait();
}
}, 100);
}}
>
<Tab
heading={<TabHeading><Text>Tab 1</Text></TabHeading>}
>
<Scene1 />
</Tab>
<Tab heading={<TabHeading><Text>Tab 2</Text></TabHeading>}>
<Scene2 />
</Tab>
<Tab heading={<TabHeading><Text>Tab 3</Text></TabHeading>}>
<Scene3 />
</Tab>
<Tab heading={<TabHeading><Text>Tab 4</Text></TabHeading>}>
<Scene4 />
</Tab>
</Tabs>`
Screenshot of emulator/device
Not necessary
Is the bug present in both ios and android or in any one of them?
Not sure. Just checked with Android. This happened in both AVD and physical devices.
Additional info
When you click a tab that is next to the last tab, the last tab will be active Ex:
- Case 1: 4 tabs, click tab 3 -> tab 4 will be active
- Case 2: 5 tabs, click tab 4 -> tab 4 will be active
This bug does not happend when we don’t change the orientation!
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
[Bug] Tabs index incorrect while set Orientation programmatically
In my case, I have 4 tabs and Tab 2 (index 1) should be in landscape mode so I used the plugin react-native-orientation...
Read more >Android ViewPager with tab not maintaining state after screen ...
After screen rotation new instance of FragmentPagerAdapter is created. But the ViewPager restores its state and state of all fragments it contains.
Read more >Possible bug: Setting SelectedTabIndex with invisible tabs
When setting tab visibility, at least programmatically via C# code behind, the current RadRibbonBar selected tab index is lost (actually ...
Read more >TabLayout | Android Developers
Auto-sizing tabs behave like MODE_FIXED with GRAVITY_CENTER while the tabs fit within the TabLayout's content width. Fixed tabs have equal width ...
Read more >Why tabView jumps one view back on orientation change?
I have a simple tabView, and when I change the orientation of my iPhone (from portrait to landscape) tab jumps one tab back....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ithieund can you try adding prop scrollWithoutAnimation={true} to Tabs
Closing this issue. See this issue https://github.com/skv-headless/react-native-scrollable-tab-view/issues/518