question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Tabs index incorrect while set Orientation programmatically

See original GitHub issue

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 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:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
akhil-gacommented, May 28, 2018

@ithieund can you try adding prop scrollWithoutAnimation={true} to Tabs

0reactions
akhil-gacommented, Jun 4, 2018
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found