Skip to content

Commit

Permalink
Merge pull request #41678 from abzokhattab/40945
Browse files Browse the repository at this point in the history
Fix enter key behaviour in the children components of the form wrapper
  • Loading branch information
blimpich authored May 13, 2024
2 parents cd11170 + bbc32e5 commit 2494c60
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/components/Form/FormWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ function FormWrapper({
enabledWhenOffline={enabledWhenOffline}
isSubmitActionDangerous={isSubmitActionDangerous}
disablePressOnEnter={disablePressOnEnter}
enterKeyEventListenerPriority={1}
/>
)}
</FormElement>
Expand Down
5 changes: 5 additions & 0 deletions src/components/FormAlertWithSubmitButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ type FormAlertWithSubmitButtonProps = {

/** Style for the error message for submit button */
errorMessageStyle?: StyleProp<ViewStyle>;

/** The priority to assign the enter key event listener to buttons. 0 is the highest priority. */
enterKeyEventListenerPriority?: number;
};

function FormAlertWithSubmitButton({
Expand All @@ -73,6 +76,7 @@ function FormAlertWithSubmitButton({
onSubmit,
useSmallerSubmitButtonSize = false,
errorMessageStyle,
enterKeyEventListenerPriority = 0,
}: FormAlertWithSubmitButtonProps) {
const styles = useThemeStyles();
const style = [!footerContent ? {} : styles.mb3, buttonStyles];
Expand Down Expand Up @@ -102,6 +106,7 @@ function FormAlertWithSubmitButton({
<Button
success
pressOnEnter={!disablePressOnEnter}
enterKeyEventListenerPriority={enterKeyEventListenerPriority}
text={buttonText}
style={style}
onPress={onSubmit}
Expand Down

0 comments on commit 2494c60

Please sign in to comment.