From e323ff1078d73a849aad3e64de7a4e0145695d7a Mon Sep 17 00:00:00 2001 From: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com> Date: Fri, 18 Nov 2022 12:24:25 +0100 Subject: [PATCH 1/2] Fixed: Pressing escape when a popover is open closes the chat and the page gets stuck in the middle --- patches/react-native-modal+13.0.0.patch | 46 +++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 patches/react-native-modal+13.0.0.patch diff --git a/patches/react-native-modal+13.0.0.patch b/patches/react-native-modal+13.0.0.patch new file mode 100644 index 0000000000000..576858f1f5f7d --- /dev/null +++ b/patches/react-native-modal+13.0.0.patch @@ -0,0 +1,46 @@ +diff --git a/node_modules/react-native-modal/dist/modal.d.ts b/node_modules/react-native-modal/dist/modal.d.ts +index b63bcfc..bd6419e 100644 +--- a/node_modules/react-native-modal/dist/modal.d.ts ++++ b/node_modules/react-native-modal/dist/modal.d.ts +@@ -161,6 +161,7 @@ export declare class ReactNativeModal extends React.Component + getDeviceHeight: () => number; + getDeviceWidth: () => number; + onBackButtonPress: () => boolean; ++ handleEscape: (e: KeyboardEvent) => void; + shouldPropagateSwipe: (evt: GestureResponderEvent, gestureState: PanResponderGestureState) => boolean; + buildPanResponder: () => void; + getAccDistancePerDirection: (gestureState: PanResponderGestureState) => number; +diff --git a/node_modules/react-native-modal/dist/modal.js b/node_modules/react-native-modal/dist/modal.js +index 80f4e75..fe028ab 100644 +--- a/node_modules/react-native-modal/dist/modal.js ++++ b/node_modules/react-native-modal/dist/modal.js +@@ -75,6 +75,13 @@ export class ReactNativeModal extends React.Component { + } + return false; + }; ++ this.handleEscape = (e) => { ++ if (e.key === 'Escape') { ++ if (this.onBackButtonPress() === true) { ++ e.stopImmediatePropagation(); ++ } ++ } ++ }; + this.shouldPropagateSwipe = (evt, gestureState) => { + return typeof this.props.propagateSwipe === 'function' + ? this.props.propagateSwipe(evt, gestureState) +@@ -454,9 +461,15 @@ export class ReactNativeModal extends React.Component { + this.open(); + } + BackHandler.addEventListener('hardwareBackPress', this.onBackButtonPress); ++ if (Platform.OS === 'web') { ++ document?.body?.addEventListener?.('keyup', this.handleEscape, true); ++ } + } + componentWillUnmount() { + BackHandler.removeEventListener('hardwareBackPress', this.onBackButtonPress); ++ if (Platform.OS === 'web') { ++ document?.body?.removeEventListener?.('keyup', this.handleEscape, true); ++ } + if (this.didUpdateDimensionsEmitter) { + this.didUpdateDimensionsEmitter.remove(); + } From f2192f1bb30c60a24cb8b499bd213240175688bb Mon Sep 17 00:00:00 2001 From: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com> Date: Fri, 18 Nov 2022 14:04:53 +0100 Subject: [PATCH 2/2] Rename react-native-modal+13.0.0.patch to react-native-modal+13.0.1.patch Patch is for 13.0.1 (although same for 13.0.0) --- ...-native-modal+13.0.0.patch => react-native-modal+13.0.1.patch} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename patches/{react-native-modal+13.0.0.patch => react-native-modal+13.0.1.patch} (100%) diff --git a/patches/react-native-modal+13.0.0.patch b/patches/react-native-modal+13.0.1.patch similarity index 100% rename from patches/react-native-modal+13.0.0.patch rename to patches/react-native-modal+13.0.1.patch