Replies: 1 comment
-
I have an upload system and in it I opened a dialog, when the user uploads I wanted it to only be able to close if the upload was finished, so I applied the following logic: You have the property: onOpenChange in the component you can change the state to both close and open the dialog. const FilesUpload = ({
user
}: {
user: User
}) => {
const [open, setOpen] = useState(false)
const [disabled, setDisabled] = useState(false)
const onOpenModal = () => {
if (disabled && open) {
return;
}
setOpen(!open)
}
const handleSubmit = async (event: MouseEvent<HTMLButtonElement, globalThis.MouseEvent>) => {
event.preventDefault()
try {
setDisabled(true)
//~your logic and promisse request
setOpen(false)
setDisabled(false)
})
} catch (error) {
console.log(error)
if (error instanceof Error) {
toast({
title: "Error",
description: error.message,
variant: "destructive",
})
}
}
}
return (
<Dialog open={open} onOpenChange={onOpenModal}>
</Dialog>
)
}
export { FilesUpload } |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I have a dialog with an iframe inside and I don't want to be allow the user to close it in any other way then to press a button in the iframe which sends a request to my parent page which closes the dialog.
I want to have custom logic on the dialog when the user wants to close it via all the ways he can close it
Beta Was this translation helpful? Give feedback.
All reactions