Toggle context menus on click and add active state #6822
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Contributor checklist:
main
branchyarn ready
run passes successfully (more about tests here)Description
Fix for a minor annoyance I had with the behaviour of the context menu at the top of the left pane. Most other menu buttons throughout the app are toggles, i.e., they show the menu on the first click and hide it on the next click. These menu buttons weren't toggles and I'd find myself clicking once to show, then a second time to hide, but the menu wouldn't go away. The buttons at the top of the left pane were also missing active states, unlike most other similar buttons including the hamburger menu.
Post-fix demo
Menu.UI.inconsistency.fixes.mov
No change to the behaviour of the menus in the conversation pane (just showed them in the demo for reference). The new behaviour is just for the triple dot menu in the left pane.
Details
ContextMenu
to toggle the menu state on click rather than always showing itopenMenu
render prop wasn't accurate anymore, so I renamed it toonClick
for consistency with the existingonKeyDown
render propContextMenu
instances weren't getting areferenceElement
set because theirref
render prop wasn't being passed downreferenceElement
, a click on the menu button was considered an outside click, which would hide the menu, so toggling would immediately bring it back 馃憥馃徎ref
-less instances and also addedforwardRef
to theNavSidebarActionButton
to get the button ref and toggling is now working as expected:active
background onNavSidebarActionButton
to match the hamburger menu