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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggle context menus on click and add active state #6822

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

smably
Copy link

@smably smably commented Mar 11, 2024

Contributor checklist:

  • My contribution is not related to translations.
  • My commits are in nice logical chunks with good commit messages
  • My changes are rebased on the latest main branch
  • A yarn ready run passes successfully (more about tests here)
  • My changes are ready to be shipped to users

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

  • Refactored ContextMenu to toggle the menu state on click rather than always showing it
    • That meant that the name of the openMenu render prop wasn't accurate anymore, so I renamed it to onClick for consistency with the existing onKeyDown render prop
  • Adding toggle logic also revealed that a bunch of ContextMenu instances weren't getting a referenceElement set because their ref render prop wasn't being passed down
    • Without a referenceElement, a click on the menu button was considered an outside click, which would hide the menu, so toggling would immediately bring it back 馃憥馃徎
    • I cleaned up the ref-less instances and also added forwardRef to the NavSidebarActionButton to get the button ref and toggling is now working as expected
  • I also added styling for the :active background on NavSidebarActionButton to match the hamburger menu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

3 participants