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

Add option.onClose for openModal fn. #27

Closed
michaltaberski opened this issue Feb 25, 2023 · 2 comments
Closed

Add option.onClose for openModal fn. #27

michaltaberski opened this issue Feb 25, 2023 · 2 comments

Comments

@michaltaberski
Copy link

michaltaberski commented Feb 25, 2023

I think adding a close handler to openModal fn could make the componet very flexible.

Imagine a scenario like this:

const confirmModal = ({question}) => new Promise(resolve => 
  openModal(ConfirmModal, onConfirm: () => resolve(true), { onClose: () => resolve(false) })
);

const isConfirmed = await confirmModal({question: "Are you sure?"});

OFC I can add an event handler to Cancel button or corner X button, but what about closing stuff programmatically from another place (eg. by clicking backdrop)?

@hairyf
Copy link

hairyf commented Jun 5, 2023

You can use @overlays/svelte as an alternative, which allows for external control of modals.

@mattjennings mattjennings mentioned this issue Oct 26, 2024
@mattjennings
Copy link
Owner

included in v2.0.0

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

No branches or pull requests

3 participants