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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modal: Allow preventing close requests #67635

Draft
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Draft

Conversation

mirka
Copy link
Member

@mirka mirka commented Dec 5, 2024

What?

Demonstrates a way for the consumer to cancel the user's close request.

Currently only implemented for close button clicks, just as a proof of concept.

Why?

How?

Testing Instructions

See the "Prevent Close Request" story for the Modal component.

@mirka mirka added [Type] Enhancement A suggestion for improvement. [Package] Components /packages/components labels Dec 5, 2024
@mirka mirka self-assigned this Dec 5, 2024
@mirka mirka force-pushed the modal-prevent-close branch from 253b1e2 to ba7c3b5 Compare December 5, 2024 14:46
@mirka mirka mentioned this pull request Dec 5, 2024
@mirka mirka force-pushed the modal-prevent-close branch from ba7c3b5 to 3b56e94 Compare December 5, 2024 14:49
Copy link
Member

@jsnajdr jsnajdr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better name for the prop could be onBeforeClose. There is prior art:

  • beforeinput DOM event on input element that allows you to change or cancel what is being typed into the input before its value is changed
  • beforeunload DOM event runs when navigating away from page, and allows to cancel the navigation

You could also await the call. Then the callback can return a promise. Sometime it takes time to do the validation. And await also doesn't mind if the callback is synchronous and returns a boolean directly. The function that calls the callback is already async.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants