Page MenuHomePhabricator

[web] Fix issue when opening menu without closing the previous
ClosedPublic

Authored by jacek on May 13 2022, 4:32 AM.
Tags
None
Referenced Files
F3404908: D4034.id12838.diff
Tue, Dec 3, 2:54 PM
Unknown Object (File)
Fri, Nov 29, 1:09 PM
Unknown Object (File)
Thu, Nov 21, 3:35 PM
Unknown Object (File)
Wed, Nov 20, 11:40 AM
Unknown Object (File)
Mon, Nov 18, 5:22 AM
Unknown Object (File)
Thu, Nov 14, 9:11 AM
Unknown Object (File)
Thu, Nov 14, 9:11 AM
Unknown Object (File)
Thu, Nov 14, 9:10 AM

Details

Summary

Fix problem described here:
https://linear.app/comm/issue/ENG-1125/opening-new-menu-without-closing-the-previous-one-doesnt-work
The source of the problem was closeMenu function provided by menu context, that cleared menu symbol just after it was updated by other menu component.
The diff introduces the following changes in the API:

  • closeMenu parameter is now menu symbol instead of node - it makes API more consistent, as setCurrentOpenMenu already operated with symbol.
  • closeMenu before clearing the menu, now checks if if was called from component that is active at the moment and clear menu only in that case.
  • to simplify managing state, menu node and symbol are merged into single state with one object inside. The main reason was to avoid executing setMenu inside callback passed to setCurrentMenu. In result, separate setMenuSumbol and setMenuNode functions were introduced, to avoid API changes.
Test Plan

Open members modal and open two menus in a row without closing first one. The issue should no longer exists.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

tomek added a reviewer: ashoat.

Adding @ashoat because the idea about using symbol came from him

ashoat requested changes to this revision.May 16 2022, 12:45 PM

Requesting changes for an answer to the inline question.

closeMenu parameter is now menu symbol instead of node - it makes API more consistent, as setCurrentOpenMenu already operated with symbol.

This was my suggestion on D3375, so I'm all for it :)

web/menu-provider.react.js
54 ↗(On Diff #12649)

It's strange to me that we would change the symbol but keep the node the same. Should this be replaced with the suggestion?

This revision now requires changes to proceed.May 16 2022, 12:45 PM
web/menu-provider.react.js
54 ↗(On Diff #12649)

Agree with it. Every symbol change is followed by replacing menu node. The current solution worked well because the node was replaced by executing renderMenu in menu component right after the symbol had changed.
There is however no reason why we should render an old menu node for this short period of time, so I think the suggested solution is better.

set node to null when updating menu symbol

This revision is now accepted and ready to land.May 17 2022, 12:27 PM