Skip to content

Commit d933194

Browse files
akwasniewskij-piasecki
authored andcommitted
Dropping handlers when components are dropped (#3619)
## Description Fixes #3608. On web, when gesture was active and its component had been dropped, the gesture was not dropped. This caused conflicts with other handlers, and prevented registering other gestures. I added a method to drop handlers in the `GestureOchestrator` and call it when component is dropped. --> ## Test plan ```ts import React from 'react'; import { useState } from 'react'; import { Pressable, TextInput } from 'react-native-gesture-handler'; export default function EmptyExample() { const [shown, setShown] = useState(true) if (!shown) { return ( <Pressable key="1" testID="other-pressable" style={{ width: 30, height: 30, backgroundColor: 'red' }} onPress={() => console.log('pressed')} /> ) } return ( <Pressable key="2" testID="bad-pressable" onPress={() => { }}> <TextInput style={{ backgroundColor: 'green', width: 100, height: 30 }} onSubmitEditing={() => setShown(false)} /> </Pressable> ) }; ```
1 parent fda19ef commit d933194

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

packages/react-native-gesture-handler/src/web/handlers/GestureHandler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,7 @@ export default abstract class GestureHandler implements IGestureHandler {
727727
protected resetConfig(): void {}
728728

729729
public onDestroy(): void {
730+
GestureHandlerOrchestrator.instance.removeHandlerFromOrchestrator(this);
730731
this.delegate.destroy(this.config);
731732
}
732733

0 commit comments

Comments
 (0)