You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HOLD for payment 2024-09-07][$250] Chat - Messages stuck highlighted when opening context menus consecutively #45524
Version Number: 9.0.7-4 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: N/A Issue reported by: Applause - Internal Team
Action Performed:
Log in to New Expensify
Navigate to any chat with existing messages
Right click on a message
Right click on another message
Click anywhere to close context menu
Expected Result:
The second clicked message should not be highlighted
Actual Result:
The second clicked message remains highlighted
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
@anmurali FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors
Show callback will set the context menu active to true, while the hide callback will toggle the context menu and set it based on the context menu visibility.
When we open the first context menu and then open the second one, the hide callback of the first and second context menus is called. The hide callback is cleared when called.
Why the hide callback is called twice?
When we open a context menu, if an existing context menu is found, it will hide it first.
hideContextMenu() will set the context menu visibility to false while runAndResetOnPopoverHide() triggers the hide callback (1st hide callback).
Because we set the visibility to false, the context menu popover onModalHide is triggered, calling another runAndResetOnPopoverHide().
Open the first context menu, hide callback is set to the first context menu hide callback (callback = 1st)
Open the 2nd context menu.
The first context menu hide callback is called (callback = empty) (hideContextMenu and runAndResetOnPopoverHide are called)
The second context menu hide callback is set (callback = 2nd)
The second context menu hide callback is called (callback = empty) (runAndResetOnPopoverHide is called by onModalHide)
Close the 2nd context menu, no hide callback is called, the highlight stays
What changes do you think we should make in order to solve the problem?
If we look at the popover without overlay initial implementation, they face this problem before and that's why they added the code to close the current context menu before opening a new one in this commit.
But if you notice in the commit, we only call runAndResetOnPopoverHide to trigger the hide callback, which means we never set the context menu visibility to false (which also means the context menu never closes, just repositioned to a new position of the 2nd context menu).
But in this resolve conflict commit, they added hideContextMenu. I believe it's because to allow opening the 2nd context menu on the same message without any problem.
Why does the double hide callback happen now? I'm pretty sure it's because the component has gone through several changes. For example, if you move the setting visibility to true here
to outside the promise, then the double hide callback won't happen since setIsPopoverVisible(false) and setIsPopoverVisible(true) are called almost right after the other, so the visibility state stays true. But in the current situation, the component has enough time to re-render the component with visibility of false, which triggers the extra runAndResetOnPopoverHide.
There solution is to wait until the current context menu is completely hidden before opening a new one. hideContextMenu second param supports a hide callback which we can use to show the second context menu after the 1st one is hidden.
if (contextMenuRef.current.instanceID) {
hideContextMenu(undefined, // show context menu);
// no need runAndResetOnPopoverHide
return;
}
// show context menu immediately
Also, there is another bug where the popover instance ID is never cleared, so contextMenuRef.current.instanceID is always true. To fix that, we need to clear it in runAndResetOnPopoverHide.
@anmurali this issue was created 2 weeks ago. Are we close to a solution? Let's make sure we're treating this as a top priority. Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!
Activity
melvin-bot commentedon Jul 16, 2024
Triggered auto assignment to @anmurali (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.lanitochka17 commentedon Jul 16, 2024
@anmurali FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors
lanitochka17 commentedon Jul 16, 2024
We think that this bug might be related to #vip-vsp
nyomanjyotisa commentedon Jul 17, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Messages stuck highlighted when opening context menus consecutively
What is the root cause of that problem?
App/src/pages/home/report/ContextMenu/ReportActionContextMenu.ts
Lines 128 to 133 in 9c509a0
if there is an already open context menu, we don't wait until the
hideContextMenudone before executingshowContextMenuWhat changes do you think we should make in order to solve the problem?
make showContextMenu and hideContextMenu functions
asyncand addawaitto thehideContextMenu()call hereRESULT
New-Expensify.19.mp4
What alternative solutions did you explore? (Optional)
melvin-bot commentedon Jul 22, 2024
@anmurali Eep! 4 days overdue now. Issues have feelings too...
bernhardoj commentedon Jul 24, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Message background is stuck when open context menu while other context menu is showing.
What is the root cause of that problem?
When we open a context menu, we pass a show and hide callback to the popover.
App/src/pages/home/report/ReportActionItem.tsx
Lines 357 to 358 in 1084706
Show callback will set the context menu active to true, while the hide callback will toggle the context menu and set it based on the context menu visibility.
When we open the first context menu and then open the second one, the hide callback of the first and second context menus is called. The hide callback is cleared when called.
Why the hide callback is called twice?
When we open a context menu, if an existing context menu is found, it will hide it first.
App/src/pages/home/report/ContextMenu/ReportActionContextMenu.ts
Lines 126 to 133 in 1084706
hideContextMenu() will set the context menu visibility to false while runAndResetOnPopoverHide() triggers the hide callback (1st hide callback).
Because we set the visibility to false, the context menu popover onModalHide is triggered, calling another runAndResetOnPopoverHide().
What changes do you think we should make in order to solve the problem?
If we look at the popover without overlay initial implementation, they face this problem before and that's why they added the code to close the current context menu before opening a new one in this commit.
App/src/pages/home/report/ContextMenu/ReportActionContextMenu.ts
Lines 126 to 133 in 1084706
But if you notice in the commit, we only call
runAndResetOnPopoverHideto trigger the hide callback, which means we never set the context menu visibility to false (which also means the context menu never closes, just repositioned to a new position of the 2nd context menu).But in this resolve conflict commit, they added
hideContextMenu. I believe it's because to allow opening the 2nd context menu on the same message without any problem.Why does the double hide callback happen now? I'm pretty sure it's because the component has gone through several changes. For example, if you move the setting visibility to true here
App/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.tsx
Line 216 in 1084706
to outside the promise, then the double hide callback won't happen since
setIsPopoverVisible(false)andsetIsPopoverVisible(true)are called almost right after the other, so the visibility state stays true. But in the current situation, the component has enough time to re-render the component with visibility of false, which triggers the extrarunAndResetOnPopoverHide.There solution is to wait until the current context menu is completely hidden before opening a new one.
hideContextMenusecond param supports a hide callback which we can use to show the second context menu after the 1st one is hidden.Also, there is another bug where the popover instance ID is never cleared, so
contextMenuRef.current.instanceIDis always true. To fix that, we need to clear it inrunAndResetOnPopoverHide.App/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.tsx
Lines 241 to 245 in 5005f59
melvin-bot commentedon Jul 24, 2024
@anmurali Still overdue 6 days?! Let's take care of this!
melvin-bot commentedon Jul 26, 2024
@anmurali 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!
melvin-bot commentedon Jul 30, 2024
@anmurali this issue was created 2 weeks ago. Are we close to a solution? Let's make sure we're treating this as a top priority. Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!
melvin-bot commentedon Jul 30, 2024
@anmurali 12 days overdue. Walking. Toward. The. Light...
65 remaining items
melvin-bot commentedon Oct 14, 2024
@anmurali, @hungvu193, @roryabraham, @bernhardoj Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
melvin-bot commentedon Oct 15, 2024
@anmurali, @hungvu193, @roryabraham, @bernhardoj Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
anmurali commentedon Oct 16, 2024
@hungvu193 is paid
Sent @bernhardoj an offer here
bernhardoj commentedon Oct 16, 2024
@anmurali I've requested in ND.
JmillsExpensify commentedon Oct 21, 2024
Can I get a payment summary with the amount for @bernhardoj?
melvin-bot commentedon Oct 21, 2024
@anmurali, @hungvu193, @roryabraham, @bernhardoj Huh... This is 4 days overdue. Who can take care of this?
anmurali commentedon Oct 22, 2024
Payment summary
JmillsExpensify commentedon Oct 24, 2024
$250 approved for @bernhardoj