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

[HOLD for payment 2023-05-16] [$1000] Enter key behavior changes after resizing window to mobile version #17206

Closed
6 tasks
kavimuru opened this issue Apr 9, 2023 · 53 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@kavimuru
Copy link

kavimuru commented Apr 9, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Open new dot on desktop
  2. Open a chat and write a message
  3. Hit “Enter” on keyboard
  4. Observe that the message is sent as expected
  5. Resize the window to show the mobile version
  6. Open a chat and write another message
  7. Hit “Enter” on keyboard

Expected Result:

The message should be sent regardless of the window size.

Actual Result:

After resizing the window to mobile version, hitting “Enter” on keyboard creates a new line instead of sending the message, which is inconsistent with the desktop version.

Workaround:

unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: v1.2.97-2
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation

2023-04-08.12.41.59.mp4
Recording.179.mp4

Expensify/Expensify Issue URL:
Issue reported by: @Nathan-Mulugeta
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1680948521534009

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01baaaae87b921beda
  • Upwork Job ID: 1645414498935029760
  • Last Price Increase: 2023-04-10
@kavimuru kavimuru added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Apr 9, 2023
@MelvinBot
Copy link

Triggered auto assignment to @bfitzexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@MelvinBot
Copy link

MelvinBot commented Apr 9, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@bfitzexpensify bfitzexpensify added the External Added to denote the issue can be worked on by a contributor label Apr 10, 2023
@melvin-bot melvin-bot bot changed the title Enter key behavior changes after resizing window to mobile version [$1000] Enter key behavior changes after resizing window to mobile version Apr 10, 2023
@MelvinBot
Copy link

Job added to Upwork: https://www.upwork.com/jobs/~01baaaae87b921beda

@MelvinBot
Copy link

Triggered auto assignment to @joekaufmanexpensify (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

@MelvinBot
Copy link

Triggered auto assignment to Contributor-plus team member for initial proposal review - @rushatgabhane (External)

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Apr 10, 2023
@MelvinBot
Copy link

Triggered auto assignment to @joelbettner (External), see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@PrashantMangukiya
Copy link
Contributor

Proposal

Please re-state the problem that we are trying to solve in this issue.

Enter key behaviour changes after resizing window to mobile/small screen etc.
i.e. After resizing the window to mobile/small screen, hitting “Enter” on keyboard creates a new line instead of sending the message, which is inconsistent with the web/large screen. Within desktop/web normal screen it will send the message when press enter.

What is the root cause of that problem?

Within <Composer> we are triggering this.triggerHotkeyActions functions via this line

onKeyPress={this.triggerHotkeyActions}

Below is the triggerHotkeyActions functions code:

triggerHotkeyActions(e) {
// Do not trigger actions for mobileWeb or native clients that have the keyboard open because for those devices, we want the return key to insert newlines rather than submit the form
if (!e || this.props.isSmallScreenWidth || this.props.isKeyboardShown) {
return;
}

We can see at line 584 if this.props.isSmallScreenWidth then it will return. So what happen here is, when we make browser screen small (like mobile size) it will detect as small screen and return from line 585, so it will not send message upon enter key pressed. This is the root cause of the problem.

What changes do you think we should make in order to solve the problem?

Within ReportActionCompose.js file update triggerHotkeyActions() function. i.e. Change if condition at line 584 as shown below:

// If condition - OLD
//if (!e || this.props.isSmallScreenWidth || this.props.isKeyboardShown) { 
//     return; 
// } 

// If condition - Updated
const isWeb = _.contains([CONST.OS.LINUX, CONST.OS.MAC_OS, CONST.OS.WINDOWS], getOperatingSystem());
if (!e || (!isWeb && this.props.isSmallScreenWidth) || this.props.isKeyboardShown) {
    return;
}

So this will solve the issue and it is working as expected. I tested in all platforms. To show how it works I uploaded video for web in results section.

What alternative solutions did you explore? (Optional)

None

Results
EnterKeySubmitComment.mp4

@hoangzinh
Copy link
Contributor

hoangzinh commented Apr 10, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

Enter key behavior changes after resizing window to mobile version

What is the root cause of that problem?

According to this condition

triggerHotkeyActions(e) {
// Do not trigger actions for mobileWeb or native clients that have the keyboard open because for those devices, we want the return key to insert newlines rather than submit the form
if (!e || this.props.isSmallScreenWidth || this.props.isKeyboardShown) {
return;
}

When enter key is pressed in small screen device or keyboard shown, it will do nothing

What changes do you think we should make in order to solve the problem?

There was discussion before in this behavior. It seems it's expected behavior on mWeb Chrome => https://github.com/Expensify/App/pull/13629/files#r1058438730

In case we want to change it, because this.props.isSmallScreenWidth doesn't fit with our use cases. I think we can have 2 options here:

  • Option 1: Checking OS system. More specific:
const isMobileOS = [CONST.OS.ANDROID, CONST.OS.IOS].includes(getOperatingSystem()); // we can define it in a lib to easy extend it later.
if (!e || isMobileOS || this.props.isKeyboardShown)
  • Option 2: I heard some conversations in our team that we should avoid checking specific OS system in code, we should split into specific file extension like .ios .native .android... So if we want to avoid option 1, I think to an alternative util, which is DeviceCapabilities.canUseTouchScreen util, which will check if device is a touchable device. I found we're using this util in several places, i.e here. More specific:
if (!e || (this.props.isSmallScreenWidth && DeviceCapabilities.canUseTouchScreen())  || this.props.isKeyboardShown)

Moreover, we should change in this Edit composer too, to keep consistency

@Pujan92
Copy link
Contributor

Pujan92 commented Apr 10, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

On web, enter key creates a new line instead of sending the message when the screen resizes to a smaller size.

What is the root cause of that problem?

For smaller screens we are not allowing the enter key to submit the form as per the below condition. As user only can send message by clicking on the send button.

if (!e || this.props.isSmallScreenWidth || this.props.isKeyboardShown) {
return;
}

What changes do you think we should make in order to solve the problem?

We should check the OS and if it is a mobile OS then only we shouldn't allow any hot key and return early.

const isMobileOS = [CONST.OS.ANDROID, CONST.OS.IOS].includes(getOperatingSystem());
if (!e || isMobileOS) {

if (!e || this.props.isSmallScreenWidth || this.props.isKeyboardShown) {
return;
}

@SOUVIGHOSH
Copy link

Proposal

Please re-state the problem that we are trying to solve in this issue.

On web, enter key creates a new line instead of sending the message when the screen resizes to a smaller size.

What is the root cause of that problem?

In src/pages/home/report/ReportActionCompose.js triggerHotkeyActions relies on this.props.isSmallScreenWidth for identifying mobile web & native clients.
So when desktop or non native browser are resized to small screen it behaves like mobile/native devices.
We need a better way to identify mobile web and native clients.

What changes do you think we should make in order to solve the problem?

I would like to propose usage of (Platform.OS)[https://reactnative.dev/docs/platform#os] to detect mobile.native clients.

triggerHotkeyActions(e) {
    // Do not trigger actions for mobileWeb or native clients that have the keyboard open because for those devices, we want the return key to insert newlines rather than submit the form
    if (
      !e ||
      Platform.OS === 'ios' ||
      Platform.OS === 'android' ||
      this.props.isKeyboardShown
    ) {
      return;
    }
    ```

@rushatgabhane
Copy link
Member

rushatgabhane commented Apr 11, 2023

@hoangzinh's proposal looks good to me! (No OS specific code, and native will behave same as web when a hardware keyboard is attached)

@joelbettner C+ reviewed 🎀 👀 🎀

@Pujan92
Copy link
Contributor

Pujan92 commented Apr 11, 2023

@rushatgabhane I think the selected proposal won't work for the mWeb and it sends the message on enter(checked in the emulator and isKeyboardShown is false for mweb).

@rushatgabhane
Copy link
Member

@Pujan92 thanks for raising that! Tested again, it works fine for mWeb.

WhatsApp.Video.2023-04-11.at.19.38.44.mp4

@Pujan92
Copy link
Contributor

Pujan92 commented Apr 11, 2023

@rushatgabhane Sorry, forgot to mention, I tried in mWeb emulator with Safari

Simulator.Screen.Recording.-.iPhone.14.-.2023-04-11.at.22.15.46.mp4

@rushatgabhane
Copy link
Member

rushatgabhane commented Apr 11, 2023

Oh man, safari :/

Great catch btw! We'll have to use platform code then. You happen to have a different approach?

@PrashantMangukiya
Copy link
Contributor

@rushatgabhane Kindly review my proposal above #17206 (comment) It is working as expected in every platform including mweb safari. Thank you.

@Pujan92
Copy link
Contributor

Pujan92 commented Apr 11, 2023

Haha.
Considering that in my proposal I am only checking for mobileOS with simpler condition(not sure whether we should consider hardware keyboard with mobile or not, otherwise it is working for all platforms)

@hoangzinh
Copy link
Contributor

@Pujan92 thanks for pointing out my proposal not work correctly. Is it a known issue on mWeb Safari? I couldn't find out any document mention about this issue in mWeb Safari

@melvin-bot melvin-bot bot added the Overdue label Apr 14, 2023
@rushatgabhane
Copy link
Member

didn't get time yet. hopefully will review today 🤞

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production labels May 9, 2023
@melvin-bot melvin-bot bot changed the title [$1000] Enter key behavior changes after resizing window to mobile version [HOLD for payment 2023-05-16] [$1000] Enter key behavior changes after resizing window to mobile version May 9, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label May 9, 2023
@melvin-bot
Copy link

melvin-bot bot commented May 9, 2023

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot
Copy link

melvin-bot bot commented May 9, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.12-0 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-05-16. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented May 9, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@rushatgabhane] The PR that introduced the bug has been identified. Link to the PR:
  • [@rushatgabhane] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@rushatgabhane] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@rushatgabhane] Determine if we should create a regression test for this bug.
  • [@rushatgabhane] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@bfitzexpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@daraksha-dk
Copy link
Contributor

Hi team, just want to share that I originally reported this bug here

cc: @bfitzexpensify

@rushatgabhane
Copy link
Member

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels May 15, 2023
@rushatgabhane
Copy link
Member

rushatgabhane commented May 16, 2023

  1. The PR that introduced the bug has been identified. Link to the PR: Standardize keyboard libs for determining when the keyboard is open #13629

  2. The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment: https://github.com/Expensify/App/pull/13629/files#r1206067430

  3. A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion: N.A. (a very tiny polish)

  4. Determine if we should create a regression test for this bug. No

  5. If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again - N.A.

@bfitzexpensify
Copy link
Contributor

Offers sent out @rushatgabhane @hoangzinh @Nathan-Mulugeta @daraksha-dk

@hoangzinh
Copy link
Contributor

Accepted offer. Thanks @bfitzexpensify

@Nathan-Mulugeta
Copy link

Just accepted the offer.

@daraksha-dk
Copy link
Contributor

Accepted the offer, thanks!

@melvin-bot melvin-bot bot added the Overdue label May 19, 2023
@joelbettner
Copy link
Contributor

@bfitzexpensify anything else we need to do here?

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels May 19, 2023
@bfitzexpensify
Copy link
Contributor

Looks like we still need to complete the bug-zero checklist cc @rushatgabhane

@melvin-bot melvin-bot bot removed the Overdue label May 22, 2023
@bfitzexpensify
Copy link
Contributor

Bump @rushatgabhane

@rushatgabhane
Copy link
Member

rushatgabhane commented May 25, 2023

@bfitzexpensify completed the checklist!

@joelbettner
Copy link
Contributor

@rushatgabhane I think the confusion is just coming from that you didn't check the actual tick boxes in this comment: #17206 (comment)

@rushatgabhane
Copy link
Member

I cannot edit other's messages. I don't have the access. So 😅

@joelbettner
Copy link
Contributor

Gotcha. I checked those off for you, @rushatgabhane.

@bfitzexpensify I also checked off the item you're tagged in from the list, because there was nothing to do for it.

@bfitzexpensify
Copy link
Contributor

Great, let's close this out then. Thanks for the work here everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests