Replies: 2 comments 2 replies
-
Great idea! It really seems like this behaviour has to be optional. We have forms inside dialogs, so it can be frustrating when users click outside accidentally and lose all the information they filled in. |
Beta Was this translation helpful? Give feedback.
-
Hey all! What would be a use case where you want to keep the Right now, the let [open, setOpen] = useState(false);
// ...
<Dialog
onClose={() => {
// Whatever check is necessary to know it is safe to close the Dialog.
if (formHasPendingChanges) {
if (window.confirm('You have unsaved changes. Are you sure?')) {
setOpen(false); // Close it anyway
}
} else {
setOpen(false); // Close
}
}}
>
...
</Dialog> |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
It would be great if there was a prop to disable closing the Dialog on outside click. This can be implemented currently by passing an empty function to the onClose prop, but consequently losing the Escape key functionality. So that solution is essentially a hack.
This thread shows a demand for the feature:
#621
Other solutions listed there like capturing the click and stopping the propagation, don't seem to work, presumably because of the deprecation of Dialog.Overlay?
Briefly looking through the code, it seems like it would be simple to toggle the call to useOutsideClick.
Beta Was this translation helpful? Give feedback.
All reactions