-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Conversation
@rayane-djouah Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
@nyomanjyotisa is it possible to disable press on enter only when the multiline input is focused? I'm thinking of using a ref for |
@nyomanjyotisa - Friendly reminder 😄 |
@rayane-djouah i think we can do something like this. Set |
@nyomanjyotisa - I think we can use some logic in const shouldDisablePressOnEnter = useCallback(() => {
if (disablePressOnEnter) {
return true;
}
const hasFocusedAutoGrowHeightInput = Object.values(inputRefs.current ?? {}).some((inputRef) => inputRef.current?.isFocused && inputRef.current?.autoGrowHeight);
return hasFocusedAutoGrowHeightInput;
}, [disablePressOnEnter, inputRefs]); |
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-08-13.at.1.31.03.AM.movAndroid: mWeb ChromeScreen.Recording.2024-08-13.at.1.45.39.AM.moviOS: NativeSimulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-08-13.at.01.25.12.mp4iOS: mWeb SafariSimulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-08-13.at.01.30.38.mp4MacOS: Chrome / SafariScreen.Recording.2024-08-13.at.1.46.15.AM.movMacOS: DesktopScreen.Recording.2024-08-13.at.1.47.29.AM.mov |
@nyomanjyotisa I think the simplest and most reliable solution to fix the bug from root would be to set App/src/components/Button/index.tsx Lines 300 to 309 in 93dc1c9
|
Kinda stuck with this, have tried the following
And set the ref values here
but cant make the |
Do you mean like this?
Not really sure if we can do it this way, I think we still need press on enter on android on several places |
@nyomanjyotisa - Yes, but using The Enter key will still work correctly on Android native due to the App/src/components/Form/InputWrapper.tsx Lines 67 to 71 in 93dc1c9
|
@@ -82,6 +84,9 @@ function FormAlertWithSubmitButton({ | |||
const style = [!footerContent ? {} : styles.mb3, buttonStyles]; | |||
const safePaddingBottomStyle = useSafePaddingBottomStyle(); | |||
|
|||
const platform = getPlatform(); | |||
const pressOnEnter = platform === CONST.PLATFORM.ANDROID ? false : !disablePressOnEnter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a comment and a link to the issue to explain why we're doing this?
Also please update the PR title and description to align with the latest changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure will do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment added with link to issue, also updated the PR title and description
Also, please include in the test steps a check for form submission with single-line input submission on Android native, and retest it. |
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
@rayane-djouah test steps updated to test Room name edit as well (single-line input), and retested |
Before fix on Samsung with Samsung keyboard(Form submitted on enter key press on multiline input):WhatsApp.Video.2024-08-12.at.8.19.03.PM.mp4After fix on Samsung with Samsung keyboard: Enter new line on enter key press on multiline input:WhatsApp.Video.2024-08-12.at.8.22.01.PM.mp4Submit form on enter key press on single-line input:WhatsApp.Video.2024-08-12.at.8.27.28.PM.mp4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM and tests well
@@ -82,6 +84,10 @@ function FormAlertWithSubmitButton({ | |||
const style = [!footerContent ? {} : styles.mb3, buttonStyles]; | |||
const safePaddingBottomStyle = useSafePaddingBottomStyle(); | |||
|
|||
// Disable pressOnEnter only for Android Native due to bug here: https://github.com/Expensify/App/issues/46644 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we explain the bug in comment please. i mean a specific reason to disable enter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the comment to add more details @MonilBhavsar
Lint failure |
lint fixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/MonilBhavsar in version: 9.0.22-0 🚀
|
🚀 Deployed to staging by https://github.com/MonilBhavsar in version: 9.0.22-1 🚀
|
🚀 Deployed to production by https://github.com/chiragsalian in version: 9.0.22-9 🚀
|
Details
disable
pressOnEnter
onFormAlertWithSubmitButton
only for android nativeFixed Issues
$ #46644
PROPOSAL:
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Room description:
WhatsApp.Video.2024-08-12.at.8.22.01.PM.mp4
Room name:
WhatsApp.Video.2024-08-12.at.8.27.28.PM.mp4
Android: mWeb Chrome
disablePressOnEnter-on-form-that-has-input-with-shouldSubmitForm-false-by-nyomanjyotisa-.-Pull-Request-46894-.-Expensify-App.1.mp4
iOS: Native
N/A
iOS: mWeb Safari
RPReplay_Final1722955601.MP4
MacOS: Chrome / Safari
-1-New-Expensify.16.mp4
MacOS: Desktop
disablePressOnEnter-on-form-that-has-input-with-shouldSubmitForm-false-by-nyomanjyotisa-.-Pull-Request-46894-.-Expensify-App.mp4