Repository navigation
Commit 2b23b88
authored
[Android] Reset the native DOWN flag for unmanaged buttons (#4590)
## Description
`ButtonViewGroup` tracks whether the native dispatch delivered DOWN for
the current gesture and resets it when the handler goes BEGAN. The reset
sat behind the `managedHandlerTag` guard, so it only ran for buttons
that manage their own handler (`Touchable`, `Pressable`). A button
attached through a detector, like `RectButton` with `useNativeGesture`,
set the flag on its first touch and never cleared it. From then on the
#4441 rule degraded to the mid-gesture check only, and a fling caught on
such a button was not cancelled.
The reset now runs before the guard, so every handler on the view gets
the per-gesture rule. Since #4582 the detector rule already covers this
case for detector-attached buttons, so there is no visible change today;
this fixes the stale state so the hook's rule holds on its own.
## Test plan
<details>
<summary>Repro</summary>
```tsx
import { useState } from 'react';
import { FlatList, StyleSheet, Text, View } from 'react-native';
import { GestureHandlerRootView, RectButton } from 'react-native-gesture-handler';
export default function App() {
const [presses, setPresses] = useState(0);
return (
<GestureHandlerRootView style={styles.flex}>
<Text style={styles.counter}>{`presses=${presses}`}</Text>
<FlatList
data={Array.from({ length: 500 }, (_, i) => i)}
keyExtractor={(item) => String(item)}
renderItem={({ item }) => (
<RectButton style={styles.row} onPress={() => setPresses((count) => count + 1)}>
<Text>Row {item}</Text>
</RectButton>
)}
/>
</GestureHandlerRootView>
);
}
const styles = StyleSheet.create({
flex: { flex: 1 },
counter: { padding: 16, paddingTop: 48, fontFamily: 'monospace' },
row: { height: 80, justifyContent: 'center', paddingLeft: 16, borderBottomWidth: 1 },
});
```
</details>1 parent 53da095 commit 2b23b88
1 file changed
Lines changed: 11 additions & 5 deletions
File tree
- packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
762 | 762 | | |
763 | 763 | | |
764 | 764 | | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
765 | 776 | | |
766 | 777 | | |
767 | 778 | | |
| |||
771 | 782 | | |
772 | 783 | | |
773 | 784 | | |
774 | | - | |
775 | | - | |
776 | | - | |
777 | | - | |
778 | | - | |
779 | 785 | | |
780 | 786 | | |
781 | 787 | | |
| |||
0 commit comments