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-07-21] [$2000] Selecting a chat message and pressing any key focus the message instead of switching the focus to the composer. #16098

Closed
2 of 6 tasks
kavimuru opened this issue Mar 18, 2023 · 143 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 Engineering External Added to denote the issue can be worked on by a contributor

Comments

@kavimuru
Copy link

kavimuru commented Mar 18, 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. Go to any chats
  2. Click on any message
  3. Press any letter.

Expected Result:

Character is typed in the message composer

Actual Result:

Message gets focused instead

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: 1.2.87-0
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:

Monosnap.screencast.2023-03-17.13-47-59.mp4
Recording.1730.mp4

Expensify/Expensify Issue URL:
Issue reported by: @pecanoro
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1679075457783789

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0108a1ba7c41369017
  • Upwork Job ID: 1640319237704986624
  • Last Price Increase: 2023-06-19
@kavimuru kavimuru added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Mar 18, 2023
@melvin-bot melvin-bot bot locked and limited conversation to collaborators Mar 18, 2023
@MelvinBot
Copy link

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

@MelvinBot
Copy link

MelvinBot commented Mar 18, 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

@sophiepintoraetz
Copy link
Contributor

Tomorrow

@Expensify Expensify unlocked this conversation Mar 21, 2023
@melvin-bot melvin-bot bot added the Overdue label Mar 22, 2023
@sophiepintoraetz
Copy link
Contributor

Hopefully have some time today - now that I'm recovering!

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Mar 23, 2023
@sophiepintoraetz
Copy link
Contributor

Reproduced!
image

@MelvinBot
Copy link

Triggered auto assignment to @PauloGasparSv (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

@PauloGasparSv
Copy link
Contributor

PauloGasparSv commented Mar 27, 2023

Making this external!

(btw, the platforms here only mention Web but I think this should work the same way for Web and Desktop so I'm checking that platform too)

@PauloGasparSv PauloGasparSv added the External Added to denote the issue can be worked on by a contributor label Mar 27, 2023
@melvin-bot melvin-bot bot changed the title Selecting a chat message and pressing any key focus the message instead of switching the focus to the composer. [$1000] Selecting a chat message and pressing any key focus the message instead of switching the focus to the composer. Mar 27, 2023
@MelvinBot
Copy link

Job added to Upwork: https://www.upwork.com/jobs/~0108a1ba7c41369017

@MelvinBot
Copy link

Current assignee @sophiepintoraetz is eligible for the External assigner, not assigning anyone new.

@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 Mar 27, 2023
@MelvinBot
Copy link

Current assignee @PauloGasparSv is eligible for the External assigner, not assigning anyone new.

@getusha
Copy link
Contributor

getusha commented Mar 27, 2023

Proposal

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

Clicking on chat message and pressing a key will focus the message instead of the composer

What is the root cause of that problem?

Since the ReportActionItem is focusable and focus-visible will be applied when we press any key on it.

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

we need to add a code where we listen for a keypress event and then focus the composer. Additionally, we want to ensure that the key pressed is preserved so that we can update the comment based on the keys that were pressed.

Screenshot 2023-03-27 at 5 27 48 AM

// Register an event listener to detect key presses
this.unsubscribeOnKeyPress = DomUtils.onKeyPress((e) => {
    // If the composer is already focused, exit early
    if (this.state.isFocused) return;

    // Otherwise, focus the composer and update the comment with the pressed key
    this.focus();
    this.updateComment(`${this.state.value}${e.key}`, true);
});

i am using keypress because it fires when a key that produces a character value is pressed down and not for other keys like ctrl shift etc.

After implementation

Screen.Recording.2023-03-27.at.5.19.23.AM.mov

What alternative solutions did you explore? (Optional)

@tienifr
Copy link
Contributor

tienifr commented Mar 27, 2023

Proposal

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

When clicking on a chat message and click on any character, the message gets focused and the composer is not.

What is the root cause of that problem?

The ReportActionItem is focusable, and we don't have any keydown listener to focus the composer, so the ReportActionItem will get focused.

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

We should make the behavior consistent with Slack, by automatically focusing on the Composer if we press on regular characters like a, b, c, d (not non-character keys like Enter, Shift) when we're not typing on any input or textarea.

This can be done by:

  1. Add a new replaceSelectionWithText(text) method so that we can insert the character in the correct cursor position that the user was in (to be consistent with Slack). This one is quite similar to the addEmojiToTextBox method that we're already using to insert the emoji.

This function will insert the text to the current cursor position in the composer, making use of the selection state and the updateComment method.
Let's say the composer currently has the text random me|ssage (the | is the current cursor position), then after pressing the letter a, the message in the composer will become random meassage.

  1. Add a new keypressListener listener method to the ReportActionCompose here and bind it in the constructor.

Here we'll check:

  • The composer is currently not focused (using this.state.isFocused)
  • The key pressed is an individual key (a, b, c, d, 1, 2, _, ...) rather than special keys like Enter, Shift (by checking event key length is 1)
  • we're not typing on another input/text area (a.k.a. the nodeName of the event target is not INPUT or `TEXTAREA)

If all the above is true, we'll focus on the composer (this.focus();) and update the composer text with the key (this.replaceSelectionWithText(e.key);)

  1. In componentDidMount here we'll listen to the keydown event and trigger keypressListener on that event.
    (We shouldn't use keypress because it's a deprecated method, also it will still capture keys like Enter so there's not much difference from keydown in our use case)

  2. Remove the event listener in 3 inside componentWillUnmount.

What alternative solutions did you explore? (Optional)

  • If we want to be more precise with the non-character key check ( if (e.key.length > 1) return;) we can go with a regex as well.
  • We need to decide what we want to do for Message edit case since there could be multiple edit messages opening at once. Slack only auto focuses on the main composer, not the edit composer. For that the above solution is enough.

@melvin-bot melvin-bot bot added the Overdue label Mar 30, 2023
@PauloGasparSv
Copy link
Contributor

Not overdue!

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 labels Jul 14, 2023
@melvin-bot melvin-bot bot changed the title [$2000] Selecting a chat message and pressing any key focus the message instead of switching the focus to the composer. [HOLD for payment 2023-07-21] [$2000] Selecting a chat message and pressing any key focus the message instead of switching the focus to the composer. Jul 14, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jul 14, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 14, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jul 14, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.40-5 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-07-21. 🎊

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 Jul 14, 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:

  • [@Santhosh-Sellavel] The PR that introduced the bug has been identified. Link to the PR:
  • [@Santhosh-Sellavel] 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:
  • [@Santhosh-Sellavel] 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:
  • [@Santhosh-Sellavel] Determine if we should create a regression test for this bug.
  • [@Santhosh-Sellavel] 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.
  • [@mallenexpensify / @sophiepintoraetz] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jul 20, 2023
@sophiepintoraetz
Copy link
Contributor

sophiepintoraetz commented Jul 24, 2023

@Santhosh-Sellavel can you complete the Checklist please? I see you are raising requests through NewDot as well, so can you fire a payment through for $2000 $1000 (given the introduction of a regression)? thank you!

@parasharrajat
Copy link
Member

parasharrajat commented Jul 24, 2023

Note: there has been another regression #23184 from this issue's PR.

@Santhosh-Sellavel
Copy link
Collaborator

Santhosh-Sellavel commented Jul 24, 2023

Please hold on from any action there @parasharrajat. I'm proposing to create a follow-up issue to tackle this issue & invest some more time to test this to capture other bugs and handle them holistically by discussing and improving the feature handling.

cc: @robertKozik @sophiepintoraetz @PauloGasparSv

@sophiepintoraetz
Copy link
Contributor

Thank you @Santhosh-Sellavel - that's a great idea. I will close this one out but let's reference this one in your master GH when you create it - lmk if you need a hand wrangling it together!

@parasharrajat
Copy link
Member

There is another #23403 regression from this

@kadiealexander
Copy link
Contributor

Reopening to get some movement on these regressions:

#23403
#23184

@Santhosh-Sellavel please feel free to close once a new issue has been created as discussed here.

@PauloGasparSv
Copy link
Contributor

Reopening to get some movement on these regressions:

#23403 #23184

@Santhosh-Sellavel please feel free to close once a new issue has been created as discussed here.

We are discussing these in this slack thread

@melvin-bot melvin-bot bot added the Overdue label Aug 9, 2023
@PauloGasparSv
Copy link
Contributor

Not overdue, still in discussion over at the thread

@melvin-bot melvin-bot bot removed the Overdue label Aug 9, 2023
@PauloGasparSv
Copy link
Contributor

Hey, we decided over at slack to close this issue and work on the 2 bugs/regressions in their respective issues instead of rolling the feature back and re-implementing it with a doc or fixing both regressions here.

I'll close this issue and comment this on each of the individual bug issues.

@JmillsExpensify
Copy link

Reviewed the details for @Santhosh-Sellavel. Approved for payment in NewDot based on the BZ summary above.

@melvin-bot
Copy link

melvin-bot bot commented Aug 17, 2023

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

@sophiepintoraetz
Copy link
Contributor

...is Melvin okay? I don't think that's correct, right @PauloGasparSv?

@Santhosh-Sellavel
Copy link
Collaborator

@sophiepintoraetz Yes Melvin is fine. This issue was a referenced in discussion or proposals

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 Engineering External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests