Skip to content

SelectMenu onOutsideClick & Portals #940

Closed
@emplums

Description

@emplums

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions