Skip to content

Commit 889a74d

Browse files
authored
buttons screen back button fix (#8303)
1 parent 72412dc commit 889a74d

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

playground/src/screens/ButtonsScreen.tsx

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable prettier/prettier */
22
import React from 'react';
3+
import { Platform } from 'react-native';
34
import { NavigationComponent, Options, OptionsTopBarButton } from 'react-native-navigation';
45
import Root from '../components/Root';
56
import Button from '../components/Button';
@@ -139,17 +140,23 @@ export default class ButtonOptions extends NavigationComponent {
139140
);
140141
}
141142

142-
toggleBack= ()=> {
143+
toggleBack = () => {
143144
this.backButtonVisibile = !this.backButtonVisibile;
144-
Navigation.mergeOptions(this.props.componentId,{
145-
topBar:{
146-
backButton:{
147-
testID:BACK_BUTTON,
148-
visible:this.backButtonVisibile
149-
}
150-
}
151-
})
152-
}
145+
Navigation.mergeOptions(this.props.componentId, {
146+
topBar: {
147+
backButton: {
148+
testID: BACK_BUTTON,
149+
visible: this.backButtonVisibile,
150+
},
151+
// iOS: leftButtons replace the back chevron slot, so the back button
152+
// can't render unless leftButtons are cleared. Android's back
153+
// affordance is independent of leftButtons.
154+
...(Platform.OS === 'ios' && this.backButtonVisibile
155+
? { leftButtons: [] }
156+
: {}),
157+
},
158+
});
159+
};
153160

154161
setRightButtons = () =>
155162
Navigation.mergeOptions(this, {

0 commit comments

Comments
 (0)