Skip to content
This repository was archived by the owner on Feb 25, 2020. It is now read-only.

Commit 9d17440

Browse files
committed
fix: fix back button not working in header
1 parent a32e43a commit 9d17440

File tree

6 files changed

+38
-56
lines changed

6 files changed

+38
-56
lines changed

example/src/HeaderPreset.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ const StackWithHeaderPreset = createStackNavigator(
109109
defaultNavigationOptions: {
110110
...TransitionPresets.SlideFromRightIOS,
111111
headerStyleInterpolator: HeaderStyleInterpolators.forUIKit,
112+
headerTitleContainerStyle: { left: null },
112113
gesturesEnabled: true,
113114
},
114115
}

src/navigators/__tests__/__snapshots__/NestedNavigator.test.tsx.snap

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -315,17 +315,12 @@ Array [
315315
<View
316316
pointerEvents="box-none"
317317
style={
318-
Array [
319-
Object {
320-
"zIndex": 0,
321-
},
322-
Object {
323-
"left": 0,
324-
"position": "absolute",
325-
"right": 0,
326-
"top": 0,
327-
},
328-
]
318+
Object {
319+
"left": 0,
320+
"position": "absolute",
321+
"right": 0,
322+
"top": 0,
323+
}
329324
}
330325
>
331326
<View
@@ -407,6 +402,7 @@ Array [
407402
}
408403
>
409404
<View
405+
pointerEvents="box-none"
410406
style={
411407
Array [
412408
null,
@@ -453,17 +449,12 @@ Array [
453449
<View
454450
pointerEvents="box-none"
455451
style={
456-
Array [
457-
Object {
458-
"zIndex": 0,
459-
},
460-
Object {
461-
"left": 0,
462-
"position": "absolute",
463-
"right": 0,
464-
"top": 0,
465-
},
466-
]
452+
Object {
453+
"left": 0,
454+
"position": "absolute",
455+
"right": 0,
456+
"top": 0,
457+
}
467458
}
468459
>
469460
<View
@@ -545,6 +536,7 @@ Array [
545536
}
546537
>
547538
<View
539+
pointerEvents="box-none"
548540
style={
549541
Array [
550542
null,

src/navigators/__tests__/__snapshots__/StackNavigator.test.tsx.snap

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,12 @@ Array [
163163
<View
164164
pointerEvents="box-none"
165165
style={
166-
Array [
167-
Object {
168-
"zIndex": 0,
169-
},
170-
Object {
171-
"left": 0,
172-
"position": "absolute",
173-
"right": 0,
174-
"top": 0,
175-
},
176-
]
166+
Object {
167+
"left": 0,
168+
"position": "absolute",
169+
"right": 0,
170+
"top": 0,
171+
}
177172
}
178173
>
179174
<View
@@ -258,6 +253,7 @@ Array [
258253
}
259254
>
260255
<View
256+
pointerEvents="box-none"
261257
style={
262258
Array [
263259
null,
@@ -291,6 +287,7 @@ Array [
291287
</Text>
292288
</View>
293289
<View
290+
pointerEvents="box-none"
294291
style={
295292
Array [
296293
Object {
@@ -480,17 +477,12 @@ Array [
480477
<View
481478
pointerEvents="box-none"
482479
style={
483-
Array [
484-
Object {
485-
"zIndex": 0,
486-
},
487-
Object {
488-
"left": 0,
489-
"position": "absolute",
490-
"right": 0,
491-
"top": 0,
492-
},
493-
]
480+
Object {
481+
"left": 0,
482+
"position": "absolute",
483+
"right": 0,
484+
"top": 0,
485+
}
494486
}
495487
>
496488
<View
@@ -575,6 +567,7 @@ Array [
575567
}
576568
>
577569
<View
570+
pointerEvents="box-none"
578571
style={
579572
Array [
580573
null,

src/views/Header/HeaderSegment.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ export default class HeaderSegment extends React.Component<Props, State> {
295295
<View pointerEvents="box-none" style={styles.content}>
296296
{onGoBack ? (
297297
<Animated.View
298+
pointerEvents="box-none"
298299
style={[styles.left, leftButtonStyle, leftContainerStyle]}
299300
>
300301
{left({
@@ -315,6 +316,7 @@ export default class HeaderSegment extends React.Component<Props, State> {
315316
) : null}
316317
{currentTitle ? (
317318
<Animated.View
319+
pointerEvents="box-none"
318320
style={[
319321
Platform.select({
320322
ios: null,
@@ -336,6 +338,7 @@ export default class HeaderSegment extends React.Component<Props, State> {
336338
) : null}
337339
{right ? (
338340
<Animated.View
341+
pointerEvents="box-none"
339342
style={[styles.right, rightButtonStyle, rightContainerStyle]}
340343
>
341344
{right({ tintColor: headerTintColor })}

src/views/Stack/Stack.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ export default class Stack extends React.Component<Props, State> {
353353
focusedOptions.headerStyleInterpolator !== undefined
354354
? focusedOptions.headerStyleInterpolator
355355
: defaultTransitionPreset.headerStyleInterpolator,
356-
style: [styles.header, styles.floating],
356+
style: styles.floating,
357357
})
358358
: null}
359359
</React.Fragment>
@@ -366,10 +366,6 @@ const styles = StyleSheet.create({
366366
flex: 1,
367367
overflow: 'hidden',
368368
},
369-
header: {
370-
// This is needed to show elevation shadow
371-
zIndex: Platform.OS === 'android' ? 1 : 0,
372-
},
373369
floating: {
374370
position: 'absolute',
375371
top: 0,

src/views/TouchableItem.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,14 @@ export default class TouchableItem extends React.Component<Props> {
4747
Platform.OS === 'android' &&
4848
Platform.Version >= ANDROID_VERSION_LOLLIPOP
4949
) {
50-
const { style, ...rest } = this.props;
50+
const { style, pressColor, borderless, children, ...rest } = this.props;
51+
5152
return (
5253
<TouchableNativeFeedback
5354
{...rest}
54-
style={null}
55-
background={TouchableNativeFeedback.Ripple(
56-
this.props.pressColor,
57-
this.props.borderless
58-
)}
55+
background={TouchableNativeFeedback.Ripple(pressColor, borderless)}
5956
>
60-
<View style={style}>{React.Children.only(this.props.children)}</View>
57+
<View style={style}>{React.Children.only(children)}</View>
6158
</TouchableNativeFeedback>
6259
);
6360
} else if (Platform.OS === 'ios') {

0 commit comments

Comments
 (0)