Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

SelectMenu onOutsideClick & Portals #940

Closed
emplums opened this issue Dec 11, 2020 · 2 comments
Closed

SelectMenu onOutsideClick & Portals #940

emplums opened this issue Dec 11, 2020 · 2 comments

Comments

@emplums
Copy link

emplums commented Dec 11, 2020

In the last major release, we removed the css overlay approach to handling showing/hiding the SelectMenu to support places where a SelectMenu might be nested inside of an absolutely positioned element.

The JS approach checks if the click happens outside of the details element that wraps the SelectMenu to determine whether or not to close the menu.

In another application that uses Primer React Components, React Portals are used to open menus in places other than where they are triggered. Because of this, the menu content no longer has a details parent, and clicking on items inside of the menu (such as the filter input) closes the menu when it should not.

  1. Should we support using menus inside of Portals? Is this an accessibility concern that we should intentionally not support?
  2. Would it make sense to add an onOutsideClick callback to SelectMenu so that users can opt out of the default SelectMenu outside click handling? Will this mess up the internal state?

Follow up items

  • Research accessibility of using menus inside of React Portals
  • Test out a custom onOutsideClick approach

cc @lerebear

@emplums
Copy link
Author

emplums commented Jan 29, 2021

I believe the approach we should use moving forward is:

  1. A reusable onOutsideClick behavior that the SelectMenu.Modal uses
  2. We pass a ref to onOutsideClick to determine what area counts as an "inside" click
  3. Someway to also ignore clicks on the trigger element?

@colebemis
Copy link
Contributor

We will soon be deprecating SelectMenu in favor of SelectPanel

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants