Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ios): ensure correct initial tab is rendered when onSwitchToTab is set #7922

Conversation

ismarbesic
Copy link
Contributor

Fixes #7921 by setting _currentTabIndex in the RNNBottomTabsController before initialization happens.

_currentTabIndex needs to be set before the super() is called, since - [RNNBottomTabsController selectedViewController] will be called during initialization and which depends on _currentTabIndex. If not set, an initial render of the tab content with index 0 will occur when tabsAttachMode is set to "onSwitchToTab".

@ismarbesic
Copy link
Contributor Author

hey @asafkorem! any chance you can help me out reviewing this PR?

@asafkorem
Copy link
Collaborator

Hey @ismarbesic, I'll review your PR soon. Thanks!

@@ -521,6 +521,40 @@ - (void)testSetRoot_withBottomTabsAttachModeOnSwitchToTab {
XCTAssertTrue(_vc2.isViewLoaded);
}

- (void)testSetRoot_withBottomTabsAttachModeOnSwitchToTabWithCustomIndex {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

@asafkorem asafkorem merged commit 985a827 into wix:master Oct 15, 2024
5 of 6 checks passed
asafkorem added a commit that referenced this pull request Oct 16, 2024
This fixes the issue mentioned on #7921, #7922 and #7924.

Changing the `selectedIndex` will not have any effect before the setup has finished,
 the original issue was the method `setSelectedIndex` was called immediately when calling
 to the `super` initializer with a `0` value regardless of the initial `currentTab`.

This prevents the loading of the tab from index `0` regardless of the custom initial rendered tab.
asafkorem added a commit that referenced this pull request Oct 16, 2024
)

This fixes the issue mentioned on #7921, #7922 and #7924.

Changing the `selectedIndex` will not have any effect before the setup has finished,
 the original issue was the method `setSelectedIndex` was called immediately when calling
 to the `super` initializer with a `0` value regardless of the initial `currentTab`.

This prevents the loading of the tab from index `0` regardless of the custom initial rendered tab.
@asafkorem
Copy link
Collaborator

asafkorem commented Oct 16, 2024

Released with v7.40.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

First tab is always rendered when onSwitchToTab and a custom currentTabIndex is set
2 participants