Skip to content

Adding the ability to differentiate between interaction types on overlay closure in useOverlay #2192

Open
@MoistCode

Description

@MoistCode

🙋 Feature Request

Add the ability to differentiate between different interactions in order to perform specific tasks such as "apply" on an outside click and "remove all changes" on escape key presses.

🤔 Expected Behavior

The event object (or some other way of interaction differentiation) should be passed through to onClose() in order for the consumer to determine what happened that cause the onClose() handler to run and how to handle it.

😯 Current Behavior

The useOverlay hook handles the behavior for overlays when an interaction happens outside of said overlay but it does not allow consumers to know what type of interaction caused the overlay to close.

💁 Possible Solution

Possibly passing the events through into onHide() which then passes it to onClose() for consumer usage?

🔦 Context

I am using the different overlay hooks to create a popover dialog that happens to contain a date picker. The behavior I require for this component is:

  • If the user clicks outside of the trigger element, apply the dates.
  • If the user presses the "Escape" key, close the popover and do nothing with the dates.

Original discussion

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions