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-12-29] [$500] mWeb/Safari - Chat - Compose box disappears while editing a message #32218

Closed
2 of 6 tasks
lanitochka17 opened this issue Nov 29, 2023 · 29 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

@lanitochka17
Copy link

lanitochka17 commented Nov 29, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 1.4.5-3
Reproducible in staging?: Y
Reproducible in production?: N
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
Expensify/Expensify Issue URL:
Issue reported by: Applause - Internal Team
Slack conversation:

Action Performed:

  1. Navigate to any conversation
  2. Tap & hold on sent msg
  3. Select edit comment
  4. Add some message
  5. With the edit message box still open, tap anywhere outside
  6. Click the green tick mark

Expected Result:

After modifying the message, we should see the compose box

Actual Result:

The compose box disappears when we modify the message

Workaround:

Unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6295040_1701284561426.0-02-01-a6584f77571a7074a9000a1a52d6496c645f2d333667779aaa1ae23cb22c82be_359313f0c2723d11.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01dc941d9d412023ac
  • Upwork Job ID: 1729965046591545344
  • Last Price Increase: 2023-11-29
  • Automatic offers:
    • alitoshmatov | Reviewer | 27987325
    • s-alves10 | Contributor | 27987326
@lanitochka17 lanitochka17 added the DeployBlockerCash This issue or pull request should block deployment label Nov 29, 2023
Copy link
Contributor

👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

Copy link

melvin-bot bot commented Nov 29, 2023

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

@tgolen
Copy link
Contributor

tgolen commented Nov 29, 2023

I'm checking this out. I didn't find anything in the list of PRs that I thought could cause this. I am now trying to run git bisect to find what caused this to change.

@tgolen
Copy link
Contributor

tgolen commented Nov 29, 2023

I was able to reproduce this on production. I am going to remove the deploy blocker label and we can work on this like a normal bug.

@tgolen tgolen removed the DeployBlockerCash This issue or pull request should block deployment label Nov 29, 2023
@tgolen tgolen removed their assignment Nov 29, 2023
@tgolen tgolen added the Bug Something is broken. Auto assigns a BugZero manager. label Nov 29, 2023
Copy link

melvin-bot bot commented Nov 29, 2023

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

Copy link

melvin-bot bot commented Nov 29, 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

@slafortune slafortune added Daily KSv2 External Added to denote the issue can be worked on by a contributor and removed Hourly KSv2 labels Nov 29, 2023
@melvin-bot melvin-bot bot changed the title mWeb/Safari - Chat - Compose box disappears while editing a message [$500] mWeb/Safari - Chat - Compose box disappears while editing a message Nov 29, 2023
Copy link

melvin-bot bot commented Nov 29, 2023

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

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

melvin-bot bot commented Nov 29, 2023

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

@slafortune
Copy link
Contributor

Actually @lanitochka17 I am not able to reproduce this on staging or production either - are you still able to?

@lanitochka17
Copy link
Author

@slafortune Only 2 out of 4 testers were able to reproduce this issue

0-02-01-60a678a07e042676074fb09d6201ac2443b2bdfe10da4a9b4375daf0238c1198_64481565b6a67213.mp4

@kpadmanabhan
Copy link

kpadmanabhan commented Nov 29, 2023

I see 2 edit boxes when I am trying to reproduce. Is that expected as per UI design? but this looks confusing to me as an end user.
image

Looking into the root cause in either case. Once I have my investigation complete, will submit a proposal.

@Krishna2323
Copy link
Contributor

Krishna2323 commented Nov 30, 2023

Proposal

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

mWeb/Safari - Chat - Compose box disappears while editing a message.

Note: This only happens when edit input & composer both are blurred and we save or delete the draft message in the

What is the root cause of that problem?

We call composerFocusKeepFocusOn whenever INPUT_FOCUSED changes in Onyx. This function refocuses on the edit message, and when we focus on the edit message input, we set setShouldShowComposeInputKeyboardAware to false, which hides the composer input. INPUT_FOCUSED is set to false whenever we delete or publish a draft message.

InputFocus.composerFocusKeepFocusOn(textInputRef.current, isFocused, modal, onyxFocused);

setShouldShowComposeInputKeyboardAware(false);

if (!isFocused && !onyxFocused && !modal.willAlertModalBecomeVisible && !modal.isVisible && refSave) {
if (!ReportActionComposeFocusManager.isFocused()) {
refSave.focus();
} else {
refSave = undefined;
}

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

IMO, the best approach is to initialize a ref to track whether the draft is published or saved. If it is, we don't need to call composerFocusKeepFocusOn. We can't remove that line because it is crucial to focus on the edit input after opening any modal when the input was focused before opening the modal.

Result

composer_lost_fix.mp4

@s-alves10
Copy link
Contributor

Proposal

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

Composer disappears when close or save the unfocused edit composer

What is the root cause of that problem?

When close or save the edit composer, deleteDraft is called. This function changes the onyx focused state to false like below

const deleteDraft = useCallback(() => {
InputFocus.callback(() => setIsFocused(false));
InputFocus.inputFocusChange(false);

This changes the onyxFocused state and composerFocusKeepFocusOn is called

useEffect(() => {
InputFocus.composerFocusKeepFocusOn(textInputRef.current, isFocused, modal, onyxFocused);
}, [isFocused, modal, onyxFocused]);

If the edit composer wasn't focused, isFocused is false and so the the edit composer input gets focused again

if (!isFocused && !onyxFocused && !modal.willAlertModalBecomeVisible && !modal.isVisible && refSave) {
if (!ReportActionComposeFocusManager.isFocused()) {
refSave.focus();
} else {

So onFocus callback is called the main composer is hidden

setShouldShowComposeInputKeyboardAware(false);

This is the root cause

Note: Clean up function is called when the edit composer gets unmounted. Why doesn't the main composer appear again?

setShouldShowComposeInputKeyboardAware(true);

All effect callbacks are called after the rendering and all clean up functions are called after the effect callbacks are called. In effect callback we focus the edit composer input and the setIsFocused was called inside the onFocus callback. But setIsFocused is asynchronous and isFocused becomes true at the next rendering. Since clean up functions are called after the effect callbacks are called before the next rendering, there is no chance for isFocused to become true. So isFocusedRef.current is still false at the time clean up is called and isActive would return false and the clean up will return early. That's why the clean up function wasn't able to show the main composer again

if (!isActive()) {
return;
}

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

We change the onyxFocused state in the deleteDraft function and this causes the refocusing. We can move this code to the clean up function
Move the below code

InputFocus.callback(() => setIsFocused(false));
InputFocus.inputFocusChange(false);

before this line

This would haven't any side effects and works perfect

Result
32218.mp4

What alternative solutions did you explore? (Optional)

We can set the isFocusedRef.current to true in the onFocus callback. This makes sense since it synchronizes the focused state and the isActive function

@tgolen
Copy link
Contributor

tgolen commented Nov 30, 2023

Just jumping in here to answer this question quickly:

I see 2 edit boxes when I am trying to reproduce. Is that expected as per UI design? but this looks confusing to me as an end user.

@kpadmanabhan I think that is expected. As to whether or not it's the best UX is a different question :D

@melvin-bot melvin-bot bot added the Overdue label Dec 2, 2023
Copy link

melvin-bot bot commented Dec 5, 2023

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

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 6, 2023
Copy link

melvin-bot bot commented Dec 6, 2023

📣 @alitoshmatov 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

Copy link

melvin-bot bot commented Dec 6, 2023

📣 @s-alves10 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@s-alves10
Copy link
Contributor

@alitoshmatov

PR is ready for review: #32598

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Dec 6, 2023
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Dec 22, 2023
@melvin-bot melvin-bot bot changed the title [$500] mWeb/Safari - Chat - Compose box disappears while editing a message [HOLD for payment 2023-12-29] [$500] mWeb/Safari - Chat - Compose box disappears while editing a message Dec 22, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Dec 22, 2023
Copy link

melvin-bot bot commented Dec 22, 2023

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

Copy link

melvin-bot bot commented Dec 22, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.15-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-12-29. 🎊

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

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Dec 22, 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:

  • [@alitoshmatov] The PR that introduced the bug has been identified. Link to the PR:
  • [@alitoshmatov] 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:
  • [@alitoshmatov] 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:
  • [@alitoshmatov] Determine if we should create a regression test for this bug.
  • [@alitoshmatov] 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.
  • [@slafortune] 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 Overdue and removed Weekly KSv2 labels Dec 28, 2023
Copy link

melvin-bot bot commented Jan 2, 2024

@tylerkaraszewski, @slafortune, @alitoshmatov, @s-alves10 Huh... This is 4 days overdue. Who can take care of this?

@alitoshmatov
Copy link
Contributor

@melvin-bot melvin-bot bot removed the Overdue label Jan 3, 2024
@alitoshmatov
Copy link
Contributor

@slafortune This one is ready for payment

@slafortune
Copy link
Contributor

All paid! Thanks @alitoshmatov !

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

8 participants