Skip to content

Modal: Allow preventing close requests - #67635

Draft
mirka wants to merge 1 commit into
trunkfrom
modal-prevent-close
Draft

mirka wants to merge 1 commit into
trunkfrom
modal-prevent-close

Conversation

@mirka

@mirka mirka commented Dec 5, 2024

Copy link
Copy Markdown
Member

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

@jsnajdr jsnajdr left a comment

Copy link
Copy Markdown
Member

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.

This branch has not been deployed

No deployments
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