From bbc32e530f3e116921692c687c85ab9f25e077f5 Mon Sep 17 00:00:00 2001 From: Abdelrahman Khattab Date: Mon, 6 May 2024 16:40:27 +0200 Subject: [PATCH] Fix enter key behaviour in the children components of the form wrapper --- src/components/Form/FormWrapper.tsx | 1 + src/components/FormAlertWithSubmitButton.tsx | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/components/Form/FormWrapper.tsx b/src/components/Form/FormWrapper.tsx index 1ba633e5c9fe..5c74fd466a15 100644 --- a/src/components/Form/FormWrapper.tsx +++ b/src/components/Form/FormWrapper.tsx @@ -118,6 +118,7 @@ function FormWrapper({ enabledWhenOffline={enabledWhenOffline} isSubmitActionDangerous={isSubmitActionDangerous} disablePressOnEnter={disablePressOnEnter} + enterKeyEventListenerPriority={1} /> )} diff --git a/src/components/FormAlertWithSubmitButton.tsx b/src/components/FormAlertWithSubmitButton.tsx index a4c8842b3113..137012478549 100644 --- a/src/components/FormAlertWithSubmitButton.tsx +++ b/src/components/FormAlertWithSubmitButton.tsx @@ -54,6 +54,9 @@ type FormAlertWithSubmitButtonProps = { /** Style for the error message for submit button */ errorMessageStyle?: StyleProp; + + /** The priority to assign the enter key event listener to buttons. 0 is the highest priority. */ + enterKeyEventListenerPriority?: number; }; function FormAlertWithSubmitButton({ @@ -73,6 +76,7 @@ function FormAlertWithSubmitButton({ onSubmit, useSmallerSubmitButtonSize = false, errorMessageStyle, + enterKeyEventListenerPriority = 0, }: FormAlertWithSubmitButtonProps) { const styles = useThemeStyles(); const style = [!footerContent ? {} : styles.mb3, buttonStyles]; @@ -102,6 +106,7 @@ function FormAlertWithSubmitButton({