Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable pressOnEnter on FormAlertWithSubmitButton only for android native #46894

Merged
merged 5 commits into from
Aug 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/components/FormAlertWithSubmitButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import type {StyleProp, ViewStyle} from 'react-native';
import {View} from 'react-native';
import useSafePaddingBottomStyle from '@hooks/useSafePaddingBottomStyle';
import useThemeStyles from '@hooks/useThemeStyles';
import getPlatform from '@libs/getPlatform';
import CONST from '@src/CONST';
import Button from './Button';
import FormAlertWrapper from './FormAlertWrapper';

Expand Down Expand Up @@ -82,6 +84,12 @@ function FormAlertWithSubmitButton({
const style = [!footerContent ? {} : styles.mb3, buttonStyles];
const safePaddingBottomStyle = useSafePaddingBottomStyle();

// Disable pressOnEnter for Android Native to avoid issues with the Samsung keyboard,
// where pressing Enter saves the form instead of adding a new line in multiline input.
// More details: https://github.com/Expensify/App/issues/46644
const isAndroidNative = getPlatform() === CONST.PLATFORM.ANDROID;
const pressOnEnter = isAndroidNative ? false : !disablePressOnEnter;

return (
<FormAlertWrapper
containerStyles={[styles.justifyContentEnd, safePaddingBottomStyle, containerStyles]}
Expand All @@ -106,7 +114,7 @@ function FormAlertWithSubmitButton({
) : (
<Button
success
pressOnEnter={!disablePressOnEnter}
pressOnEnter={pressOnEnter}
enterKeyEventListenerPriority={enterKeyEventListenerPriority}
text={buttonText}
style={style}
Expand Down
Loading