-
-
Notifications
You must be signed in to change notification settings - Fork 378
Open
Labels
component: dialogChanges related to the dialog component.Changes related to the dialog component.status: waiting for maintainerThese issues haven't been looked at yet by a maintainer.These issues haven't been looked at yet by a maintainer.
Description
Feature request
Summary
ad prop to <Dialog.Close> or <Dialog.Trigger> to await triggering closing a dialog upon success
Examples
function SaveDialog() {
const mutation = useMutation({
mutationFn: (data) => saveData(data),
});
return (
<Dialog.Root>
<Dialog.Trigger>Open Dialog</Dialog.Trigger>
<Dialog.Portal>
<Dialog.Backdrop />
<Dialog.Viewport>
<Dialog.Popup>
<Dialog.Title>Confirm Changes</Dialog.Title>
<Dialog.Description>
Are you sure you want to proceed with this update?
</Dialog.Description>
<div className="controls">
<Dialog.Close>
Cancel
</Dialog.Close>
<Dialog.Close
resolve={() => mutation.mutateAsync()}
className="confirm-button"
>
Confirm
</Dialog.Close>
</div>
</Dialog.Popup>
</Dialog.Viewport>
</Dialog.Portal>
</Dialog.Root>
);
}Motivation
The dialog like components where there is a <Dialog.Trigger> or similar, can only handle syncronous events.
I would like a variation like <Dialog.AsyncTrigger resolve={promise}> to handle scenario where
user open a dialog, the footer has a button that does trigger an async action e.g. "Save" and then close the dialog upon success, and I don't have to add useState to control it to have a cleaner component composition.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
component: dialogChanges related to the dialog component.Changes related to the dialog component.status: waiting for maintainerThese issues haven't been looked at yet by a maintainer.These issues haven't been looked at yet by a maintainer.