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

Fix: mWeb- Unable to move to another line by clicking "return" button #7920

Merged
merged 8 commits into from
Mar 11, 2022

Conversation

ahmdshrif
Copy link
Contributor

@ahmdshrif ahmdshrif commented Feb 25, 2022

Details

Fixed Issues

$ #7678

Tests

  • Verify that no errors appear in the JS console

PR Review Checklist

Contributor (PR Author) Checklist

  • I made sure to pull main before submitting my PR for review
  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I clearly indicated the environment tests should be run in (Staging vs Production)
  • I wrote testing steps that cover success & fail scenarios (if applicable)
  • I ran the tests & they passed on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified there are no console errors related to changes in this PR
  • I followed proper code patterns (see Reviewing the code)
    • I added comments when the code was not self explanatory
    • I put all copy / text shown in the product in all src/languages/* files (if applicable)
    • I followed proper naming convention for platform-specific files (if applicable)
    • I followed style guidelines (in Styling.md) for all style edits I made
  • I followed the guidelines as stated in the Review Guidelines

PR Reviewer Checklist

  • I verified the Author pulled main before submitting the PR
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the testing environment is mentioned in the test steps
  • I verified testing steps cover success & fail scenarios (if applicable)
  • I verified tests pass on all platforms & I tested again on all platforms
  • I checked that screenshots or videos are included for tests on all platforms
  • I verified there are no console errors related to changes in this PR
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified comments were added when the code was not self explanatory
    • I verified any copy / text shown in the product was added in all src/languages/* files (if applicable)
    • I verified proper naming convention for platform-specific files was followed (if applicable)
    • I verified style guidelines were followed
  • I verified that this PR follows the guidelines as stated in the Review Guidelines

QA Steps

1- Log with any account
2- Navigate to Settings > Workspace > Manage members > Invite
3- Start typing in the custom message field
4- Hit "return" button
5- make sure enter make new line

  • Verify that no errors appear in the JS console

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

Screen.Recording.2022-02-25.at.8.32.29.PM.mov

Mobile Web

Screen.Recording.2022-02-25.at.8.29.42.PM.mov

Desktop

Screen.Recording.2022-02-25.at.8.45.36.PM.mov

iOS

Screen.Recording.2022-02-25.at.8.31.26.PM.mov

Android

Screen.Recording.2022-02-25.at.8.40.10.PM.mov

@ahmdshrif ahmdshrif marked this pull request as ready for review February 25, 2022 18:35
@ahmdshrif ahmdshrif requested a review from a team as a code owner February 25, 2022 18:35
@MelvinBot MelvinBot removed the request for review from a team February 25, 2022 18:35
src/components/Button.js Outdated Show resolved Hide resolved
@ahmdshrif ahmdshrif changed the title fix: mWeb- Unable to move to another line by clicking "return" button [Hold] fix: mWeb- Unable to move to another line by clicking "return" button Feb 26, 2022
@parasharrajat
Copy link
Member

HOLD for #7702

Copy link
Contributor

@luacmartins luacmartins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good! But I'll have to test once the hold is removed.

@parasharrajat
Copy link
Member

#7702 is broken into multiple PRs and now we need to hold for #8059 which is ready for merge.

@rushatgabhane
Copy link
Member

rushatgabhane commented Mar 11, 2022

@parasharrajat @ahmdshrif event bubbling is now live

@ahmdshrif
Copy link
Contributor Author

thanks, rushatgabhane will work on this now.

@parasharrajat
Copy link
Member

Awesome @rushatgabhane. Thanks for the heads up.
@ahmdshrif Please merge main before doing changes. Now TextArea comparison logic should work.

@ahmdshrif ahmdshrif changed the title [Hold] fix: mWeb- Unable to move to another line by clicking "return" button Fix: mWeb- Unable to move to another line by clicking "return" button Mar 11, 2022
@ahmdshrif
Copy link
Contributor Author

ahmdshrif commented Mar 11, 2022

@parasharrajat this does not work after merge main also

if (this.props.isDisabled || this.props.isLoading || !e || e.target.nodeName === 'textarea' ) {
               return;
           }

I do some debug to see where this issue come form

if (_.isFunction(callback.callback)) {
callback.callback(event);
}
event.preventDefault();

here we call the callback if it exists and it returns but this function will continue and will call event.preventDefault();
which stop the default behavior of the key on textinput (to make new line)

so changing on callback will not effect

if the event.preventDefault(); not needed we can delete it otherwise we need to add new param like activeOnTextArea
and return early before preventDefault called. the same we do with pressOnEnter but new param only for textArea

@parasharrajat
Copy link
Member

Oh, shoot. Let's raise the same point on the related PR. I will try to see why are we preventing default for no reason. If this is needed, I would say to add a new param to subscription shouldPreventDefault which will skip event.preventDefault call when false.

@parasharrajat
Copy link
Member

@ahmdshrif Ok, I did some research and I think preventDefault is necessary for some cases for Lib to work.

This is the action plan now.

  1. Add a new param shouldPreventDefault:Boolean defaults to true to the KeyboardShortcut.subscribe.
  2. Save this property on the eventHandlers object.
  3. in bindHandlerToKeydownEvent. Add an if check around the event.preventDefault call that if shouldPreventDefault is true run it.
  4. Add the logic same as Fix: mWeb- Unable to move to another line by clicking "return" button  #7920 (comment) which I suggested.
  5. In the Button.js where we are subscribing set shouldPreventDefault=false.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 11, 2022

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@Ahmed
Copy link

Ahmed commented Mar 11, 2022 via email

@ahmdshrif
Copy link
Contributor Author

I wite the comment before seeing your comment 😅

ok, shoudpreventDefault is working fine I push it.

also, I think about it we need this option for example on the report screen we need to preventDefault enter key to not make a new line and send at the same time.

but there is another way to make shoudpreventDefault an option. the callback already has access to event object a so we can remove it and if he wants to preventDefault he can call it on the callback.

@ahmdshrif ahmdshrif force-pushed the fix/newline-return branch from aaf9bd3 to 4907af7 Compare March 11, 2022 12:50
@parasharrajat
Copy link
Member

I saw what you mean but it is possible that there are many event listeners attached and manipulating the native property is a bad practice.

src/libs/KeyboardShortcut/index.js Outdated Show resolved Hide resolved
src/libs/KeyboardShortcut/index.js Outdated Show resolved Hide resolved
src/components/Button.js Outdated Show resolved Hide resolved
ahmdshrif and others added 2 commits March 11, 2022 15:50
Co-authored-by: Rajat Parashar <parasharrajat@users.noreply.github.com>
Co-authored-by: Rajat Parashar <parasharrajat@users.noreply.github.com>
src/components/Button.js Outdated Show resolved Hide resolved
Co-authored-by: Rajat Parashar <parasharrajat@users.noreply.github.com>
Copy link
Member

@parasharrajat parasharrajat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a critical issue https://expensify.slack.com/archives/C01GTK53T8Q/p1647009526394119 which prevents testing the PR as it is. Although, I am sure that it works. But I am leaving this to Carlos.

@luacmartins
Copy link
Contributor

I think we should fix that issue and fully test this PR before merging it!

@ahmdshrif
Copy link
Contributor Author

I think the context issue is affected disabled and loading button which has not changed in this pr.
otherwise, the changes solve the return button issue. and we can test it. since it's now working fine on all cases.

Copy link
Member

@parasharrajat parasharrajat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. That was not a real bug. Debugger going nuts.

cc: @luacmartins

PR Reviewer Checklist

  • I verified the PR has a small number of commits behind main
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the testing environment is mentioned in the test steps
  • I verified testing steps cover success & fail scenarios (if applicable)
  • I checked that screenshots or videos are included for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • I verified there are no console errors related to changes in this PR
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified comments were added when the code was not self explanatory
    • I verified any copy / text shown in the product was added in all src/languages/* files (if applicable)
    • I verified proper naming convention for platform-specific files was followed (if applicable)
    • I verified style guidelines were followed
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components are not impacted by changes in this PR (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified the UI performance was not affected (the performance is the same than main branch)
  • If a new component is created I verified that a similar component doesn't exist in the codebase

🎀 👀 🎀 C+ reviewed

Copy link
Contributor

@luacmartins luacmartins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and tested well! Thanks for the changes!

@luacmartins luacmartins merged commit f0e39dc into Expensify:main Mar 11, 2022
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @luacmartins in version: 1.1.43-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @roryabraham in version: 1.1.43-2 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants