Commit 7f90209
authored
Fix android ripple color bug on fabric (#3369)
## Description
Android ripple currently does not work on `Fabric`, as all values passed
to `RawButton` and it's inheritors are passed through `processColor`,
which is crucial on `Paper`, and broken on `Fabric`.
This PR disables usage of `processColor`, when running on `Fabric`.
Note: `isFabric` cannot be moved out of the body of the `Pressable`, as
it likely won't be initialised before the `Pressable` starts being
rendered. More details
[here](https://github.com/software-mansion/react-native-gesture-handler/blob/b3d8fd91dca195267bdc33aa20fd6f5cd37d7fe2/src/utils.ts#L47).
Fixes #3246
Fixes #3312
Supersedes #3250
Likely could add a workaround for
software-mansion/react-native-reanimated#6935
## Test plan
<details>
<summary>
Collapsed test code
</summary>
```tsx
import React from 'react';
import { Pressable as RNPressable, StyleSheet, Text } from 'react-native';
import {
BaseButton,
GestureHandlerRootView,
RectButton,
Pressable,
} from 'react-native-gesture-handler';
const App = () => {
return (
<GestureHandlerRootView>
<RectButton style={styles.wrapperCustom} rippleColor={'blue'}>
<Text style={styles.text}>RectButton</Text>
</RectButton>
<BaseButton style={styles.wrapperCustom} rippleColor={'blue'}>
<Text style={styles.text}>BaseButton</Text>
</BaseButton>
<Pressable
style={styles.wrapperCustom}
android_ripple={{ color: 'blue' }}>
{({ pressed }) => (
<Text style={styles.text}>
{pressed ? 'Pressed!' : 'Pressable from react-native'}
</Text>
)}
</Pressable>
<RNPressable
style={styles.wrapperCustom}
android_ripple={{ color: 'blue' }}>
{({ pressed }) => (
<Text style={styles.text}>
{pressed ? 'Pressed!' : 'Pressable from react-native'}
</Text>
)}
</RNPressable>
<Pressable
style={styles.wrapperCustom}
android_ripple={{ color: '#00f' }}>
{({ pressed }) => (
<Text style={styles.text}>
{pressed ? 'Pressed!' : 'Pressable from react-native'}
</Text>
)}
</Pressable>
<RNPressable
style={styles.wrapperCustom}
android_ripple={{ color: '#00f' }}>
{({ pressed }) => (
<Text style={styles.text}>
{pressed ? 'Pressed!' : 'Pressable from react-native'}
</Text>
)}
</RNPressable>
</GestureHandlerRootView>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
gap: 16,
padding: 16,
},
text: {
fontSize: 32,
},
wrapperCustom: {
borderRadius: 8,
padding: 6,
flex: 1,
backgroundColor: 'papayawhip',
borderColor: 'red',
borderWidth: 2,
},
logBox: {
flex: 1,
padding: 20,
margin: 10,
borderWidth: StyleSheet.hairlineWidth,
borderColor: '#f0f0f0',
backgroundColor: '#f9f9f9',
},
});
export default App;
```
</details>1 parent 1e21262 commit 7f90209
File tree
3 files changed
+36
-8
lines changed- src/components
- Pressable
3 files changed
+36
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| 28 | + | |
| 29 | + | |
27 | 30 | | |
28 | 31 | | |
29 | 32 | | |
| |||
120 | 123 | | |
121 | 124 | | |
122 | 125 | | |
123 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
124 | 135 | | |
125 | 136 | | |
126 | 137 | | |
127 | 138 | | |
128 | | - | |
| 139 | + | |
129 | 140 | | |
130 | 141 | | |
131 | 142 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
3 | 8 | | |
4 | 9 | | |
5 | 10 | | |
| |||
16 | 21 | | |
17 | 22 | | |
18 | 23 | | |
19 | | - | |
| 24 | + | |
20 | 25 | | |
21 | 26 | | |
22 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
367 | 369 | | |
368 | 370 | | |
369 | 371 | | |
370 | | - | |
371 | | - | |
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
| |||
381 | 381 | | |
382 | 382 | | |
383 | 383 | | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
384 | 396 | | |
385 | 397 | | |
386 | 398 | | |
| |||
389 | 401 | | |
390 | 402 | | |
391 | 403 | | |
392 | | - | |
| 404 | + | |
393 | 405 | | |
394 | 406 | | |
395 | 407 | | |
| |||
0 commit comments