Skip to content

Commit

Permalink
Fix tabBar visibility (#6276)
Browse files Browse the repository at this point in the history
Hiding bottom tabs through static options during push transitions broke in 6.7.0.

Closes #6268
  • Loading branch information
yogevbd authored Jun 8, 2020
1 parent 3727728 commit ab63850
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
8 changes: 8 additions & 0 deletions e2e/BottomTabs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,12 @@ describe('BottomTabs', () => {
await elementById(TestIDs.POP_BTN).tap();
await expect(elementById(TestIDs.BOTTOM_TABS)).toBeVisible();
});

it('hide Tab Bar on push from second bottomTabs screen', async () => {
await elementById(TestIDs.SWITCH_TAB_BY_INDEX_BTN).tap();
await elementById(TestIDs.HIDE_TABS_PUSH_BTN).tap();
await expect(elementById(TestIDs.BOTTOM_TABS)).toBeNotVisible();
await elementById(TestIDs.POP_BTN).tap();
await expect(elementById(TestIDs.BOTTOM_TABS)).toBeVisible();
});
});
2 changes: 1 addition & 1 deletion lib/ios/RNNBasePresenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ - (BOOL)getStatusBarVisibility {
}

- (BOOL)hidesBottomBarWhenPushed {
RNNNavigationOptions *withDefault = [self.boundViewController.topMostViewController.resolveOptions withDefault:self.defaultOptions];
RNNNavigationOptions *withDefault = (RNNNavigationOptions *)[[self.boundViewController.topMostViewController.resolveOptions withDefault:self.defaultOptions] mergeOptions:self.boundViewController.options];

This comment has been minimized.

Copy link
@N3TC4T

N3TC4T Jun 9, 2020

Contributor

using mergeOptions will not apply options applied by static options

static options() {
        return {
            topBar: { visible: false },
            bottomTabs: { visible: false },
        };
    }

I replaced mergeOptions with overrideOptions and it's worked. not sure if I did it right ?

This comment has been minimized.

Copy link
@N3TC4T

N3TC4T Jun 9, 2020

Contributor

Setting bottomTabs: { visible: true }, in setDefaultOptions was causing this, not sure we need to use overrideOptions to override the default options as well.

This comment has been minimized.

Copy link
@guyca

guyca Jun 9, 2020

Collaborator

@N3TC4T mergeOptions only applies the options passed to it. It does not reapply static options or default options.

This comment has been minimized.

Copy link
@N3TC4T

N3TC4T Jun 9, 2020

Contributor

@guyca, Thanks , this is what I thought as well.

return ![withDefault.bottomTabs.visible getWithDefaultValue:YES];
}

Expand Down
8 changes: 7 additions & 1 deletion playground/src/screens/SecondBottomTabScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const {
PUSH_BTN,
PUSHED_BOTTOM_TABS,
SIDE_MENU_TAB,
FLAT_LIST_BTN
FLAT_LIST_BTN,
HIDE_TABS_PUSH_BTN
} = require('../testIDs')

class SecondBottomTabScreen extends React.Component {
Expand Down Expand Up @@ -37,10 +38,15 @@ class SecondBottomTabScreen extends React.Component {
<Button label='Push' onPress={this.push} />
<Button label='Push BottomTabs' testID={PUSH_BTN} onPress={this.pushBottomTabs} />
<Button label='SideMenu inside BottomTabs' testID={SIDE_MENU_INSIDE_BOTTOM_TABS_BTN} onPress={this.sideMenuInsideBottomTabs} />
<Button label='Hide Tabs on Push' testID={HIDE_TABS_PUSH_BTN} onPress={this.hideTabsOnPush} />
</Root>
);
}

hideTabsOnPush = () => Navigation.push(this, component(Screens.Pushed, {
bottomTabs: { visible: false }
}));

push = () => Navigation.push(this, Screens.Pushed);

pushBottomTabs = () => Navigation.push(this, {
Expand Down

0 comments on commit ab63850

Please sign in to comment.