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 2024-01-05] [$500] Web - Message background color is stuck on cancel delete #28029

Closed
1 of 6 tasks
kbecciv opened this issue Sep 22, 2023 · 110 comments
Closed
1 of 6 tasks
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

@kbecciv
Copy link

kbecciv commented Sep 22, 2023

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


Action Performed:

  1. Open the app
  2. Open any report
  3. Send any message
  4. Right click on that message and click on delete comment
  5. Click on cancel and now observe that irrespective on whichever message we hover, background color is stuck on message used in step 4

Expected Result:

App should remove background color from message as soon as we hover on any other message

Actual Result:

Background color on message is stuck when we right click on any message, click delete and cancel the delete

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.3.73.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: Any additional supporting documentation

background.color.on.message.is.stuck.on.delete.and.cancel.mp4
Recording.4693.mp4

Expensify/Expensify Issue URL:
Issue reported by: @dhanashree-sawant
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1695223040847299

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~013ba33594e38dfae9
  • Upwork Job ID: 1705250597563105280
  • Last Price Increase: 2023-10-13
  • Automatic offers:
    • bernhardoj | Contributor | 28037564
@kbecciv kbecciv added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 22, 2023
@melvin-bot melvin-bot bot changed the title Web - Message background color is stuck on cancel delete [$500] Web - Message background color is stuck on cancel delete Sep 22, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 22, 2023

Job added to Upwork: https://www.upwork.com/jobs/~013ba33594e38dfae9

@melvin-bot
Copy link

melvin-bot bot commented Sep 22, 2023

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

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

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 22, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 22, 2023

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

@Samueljh1
Copy link
Contributor

Samueljh1 commented Sep 22, 2023

Proposal

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

The problem is that the background highlight colour on a selected message does not disappear when selecting the 'Delete Comment' popup modal and then cancelling the operation.

What is the root cause of that problem?

The issue is that the onPopoverHide() callback to handle state updates can only be called once, due to the use of the 'run and reset' paradigm. In this specific situation, this callback needs to be handled twice – once when the context menu closes, and again when the confirm delete modal changes. Since this callback is called first when the context menu closes, the subsequent cancellation of the delete modal does not call the callback to update the state of the component.

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

We allow the onPopoverHide() callback to be called several times, by not clearing the callback after the first run.

I already have a simple and elegant working solution that only requires three lines of code to be changed.

@melvin-bot
Copy link

melvin-bot bot commented Sep 22, 2023

📣 @Samueljh1! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@Samueljh1
Copy link
Contributor

Contributor details
Your Expensify account email: [email protected]
Upwork Profile Link: https://www.upwork.com/freelancers/~01a7dc17eccbc9dc59

@melvin-bot
Copy link

melvin-bot bot commented Sep 22, 2023

⚠️ Invalid email. Please make sure to create an Expensify account with this email first here.

@Samueljh1
Copy link
Contributor

Contributor details
Your Expensify account email: [email protected]
Upwork Profile Link: https://www.upwork.com/freelancers/~01a7dc17eccbc9dc59

@melvin-bot
Copy link

melvin-bot bot commented Sep 22, 2023

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@dukenv0307
Copy link
Contributor

dukenv0307 commented Sep 23, 2023

Proposal

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

Background color on message is stuck when we right click on any message, click delete and cancel the delete

What is the root cause of that problem?

When closing the context menu, we toggle the state in the ReportActionItem here so it will set isContextMenuActive to false and the background color will disappear.

But we're not doing the same for the delete modal, for the delete modal we just reset the state at PopoverReportActionContextMenu, but the ReportActionItem is not aware of it.

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

We need to call the toggleContextMenuFromActiveReportAction when the delete modal closes as well.

Steps:

  • Add another onDeleteModalHide param to here with value toggleContextMenuFromActiveReportAction, so it will reset the context menu isContextMenuActive after the delete modal closes
false,
false,
toggleContextMenuFromActiveReportAction
  • Add onDeleteModalHide to the showContextMenu as well here
onDeleteModalHide = () => {}

and here

onDeleteModalHide,

. And set it to onDeleteModalHideRef in PopoverReportActionContextMenu showContextMenu.

const onDeleteModalHideRef = useRef(() => {});
onDeleteModalHideRef.current = onDeleteModalHide;
  • Call it inside hideDeleteModal here
callbackWhenDeleteModalHide.current = () => (onCancelDeleteModal.current = runAndResetCallback(() => {
    onCancelDeleteModal.current();
    onDeleteModalHideRef.current();
}));

Or we can add onDeleteModalHide to the callback of showDeleteModal when we call it from the context menu item

This is the same way we're handling it when the context menu hides, we just apply the same for when delete modal hides.

What alternative solutions did you explore? (Optional)

NA

@s-alves10
Copy link
Contributor

s-alves10 commented Sep 23, 2023

Proposal

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

Background color of the message is stuck when we click delete from context menu(right click) and click cancel on delete modal

What is the root cause of that problem?

When we right click on the message, isContextMenuActive becomes true

setIsContextMenuActive(true);

When we click the delete button, context menu hides and delete confirm modal is opened.
When context menu hides, we reset the context menu state and isContextMenuActive becomes false, but this value becomes true again when confirm delete modal is opened.
When cancel the deletion, we reset the context menu state by clearActiveReportAction

hideContextMenu(false, () => showDeleteModal(reportID, reportAction, true, clearActiveReportAction, clearActiveReportAction));

The problem is that the ReportActionItem component is not re-rendered after the delete modal hides, so the isContextMenuActive remains true and background color is stuck

This is the root cause

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

We need to prevent re-render when confirm modal shows so isContextMenuActive remains false as we click delete in hover menu

What's the root cause of re-rendering when confirm delete modal is opened?
When we right click, isContextMenuActive becomes true here. The new value would be active at the next rendering cycle. So at the next re-render, isContextMenuActive becomes true, but the isActiveReportActionForMenu value here still remains false because there are some delays until context menu state is updated(You can see this by this code segment)
In this step,

    isActiveReportActionForMenu = false
    isContextMenuActive = true

When user clicks delete button, toggleContextMenuFromActiveReportAction is called after the context menu hides. At this step, context menu state was reset already and ReportActionContextMenu.isActiveReportAction returns false. So isContextMenuActive becomes false at the next re-render.

At the next rendering cycle, isContextMenuActive is false, but isActiveReportActionForMenu becomes true because we open confirm delete modal after context menu hides.
At this step,

    isActiveReportActionForMenu = true
    isContextMenuActive = false

This change of isActiveReportActionForMenu value runs the useEffect callback [here](https://github.com/Expensify/App/blob/5aa7f6da94ddb1c8ca55a6cce714555f819c1dd0/src/pages/home/report/ReportActionItem.js#L145) and this causes the re-render. At the next re-render,

    isActiveReportActionForMenu = true
    isContextMenuActive = true

As you can see, change of isActiveReportActionForMenu value is the root cause of re-render when confirm modal opens.

In order to avoid this, I suggest to call the hide callback when delete modal hides.
As you know, delete modal and context menu defines together if the context menu is active. So when delete modal opens from the context menu, don't call the hide callback and call that when delete modal hides. That is, the menu is active while context menu or delete modal is opened

To do this

  1. Add a new ref variable callAndResetHideCallbackRef to PopoverReportActionContextMenu
    const callAndResetHideCallbackRef = useRef(true);
  1. Add a new parameter callAndResetHideCallback with default value true to the hideContextMenu function
    const hideContextMenu = (onHideActionCallback, callAndResetHideCallback= true) => {
        ...

        callAndResetHideCallbackRef.current = callAndResetHideCallback;
    };
  1. Update
    onPopoverHide.current = runAndResetCallback(onPopoverHide.current);

    to
        if (callAndResetHideCallbackRef.current) {
            onPopoverHide.current = runAndResetCallback(onPopoverHide.current);
        }
  1. Add the following line to the onModalHide callback of ConfirmModal
            onPopoverHide.current = runAndResetCallback(onPopoverHide.current);
  1. Add a parameter callAndResetHideCallback to the hideContextMenu function in ReportActionContextMenu as well
  2. Add the last parameter false below
            hideContextMenu(false, () => showDeleteModal(reportID, reportAction, true, clearActiveReportAction, clearActiveReportAction), false);

And I think we can remove this line

setIsContextMenuActive(true);

This works fine

Result
28029.mp4

What alternative solutions did you explore? (Optional)

We need to re-render the ReportActionItem component when the confirm delete modal hides
We can add props modal from Onyx store with key ONYXKEYS.MODAL
This will re-render the component when modal is hide and isContextMenuActive would be updated with the latest value

@melvin-bot melvin-bot bot added the Overdue label Sep 25, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 26, 2023

@anmurali, @thesahindia Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@thesahindia
Copy link
Member

@anmurali, I am not getting enough time to review the proposals here. Please reassign.

@melvin-bot melvin-bot bot removed the Overdue label Sep 26, 2023
@thesahindia thesahindia removed their assignment Sep 26, 2023
@melvin-bot melvin-bot bot added the Overdue label Sep 29, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 29, 2023

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@Samueljh1
Copy link
Contributor

@anmurali bump

@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 2023

@anmurali Eep! 4 days overdue now. Issues have feelings too...

@anmurali anmurali removed the External Added to denote the issue can be worked on by a contributor label Oct 4, 2023
@bernhardoj
Copy link
Contributor

PR is ready

cc: @parasharrajat

@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 29, 2023
@melvin-bot melvin-bot bot changed the title [$500] Web - Message background color is stuck on cancel delete [HOLD for payment 2024-01-05] [$500] Web - Message background color is stuck on cancel delete Dec 29, 2023
Copy link

melvin-bot bot commented Dec 29, 2023

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Dec 29, 2023
Copy link

melvin-bot bot commented Dec 29, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.19-2 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 2024-01-05. 🎊

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 29, 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:

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

@parasharrajat parasharrajat mentioned this issue Jan 2, 2024
59 tasks
@parasharrajat
Copy link
Member

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:

Regression Test Steps

  1. Open any chat
  2. Send a message
  3. Right-click or long-press the message
  4. Choose Delete message
  5. Press Cancel
  6. Verify the message is not highlighted

Do you agree 👍 or 👎 ?

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Jan 5, 2024
Copy link

melvin-bot bot commented Jan 8, 2024

@anmurali, @blimpich, @parasharrajat, @bernhardoj Whoops! This issue is 2 days overdue. Let's get this updated quick!

@anmurali
Copy link

Payment summary for contributor payments on New Dot
-[ ] $500 to @parasharrajat on ND is approved to process

@melvin-bot melvin-bot bot removed the Overdue label Jan 10, 2024
@anmurali
Copy link

@dhanashree-sawant - sent you an offer

@dhanashree-sawant
Copy link

Thanks @anmurali, I have accepted the offer.

@melvin-bot melvin-bot bot added the Overdue label Jan 12, 2024
Copy link

melvin-bot bot commented Jan 15, 2024

@anmurali, @blimpich, @parasharrajat, @bernhardoj Huh... This is 4 days overdue. Who can take care of this?

@parasharrajat
Copy link
Member

Let's close this issue. I will request it later.

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Jan 16, 2024
Copy link

melvin-bot bot commented Jan 19, 2024

@anmurali, @blimpich, @parasharrajat, @bernhardoj Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@anmurali
Copy link

@dhanashree-sawant is paid. @parasharrajat - I will let you request this when you are ready.

@melvin-bot melvin-bot bot removed the Overdue label Jan 22, 2024
@parasharrajat
Copy link
Member

Payment requested as per #28029 (comment)

@JmillsExpensify
Copy link

$500 approved for @parasharrajat

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