You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, is there a way to disable the closing of an dialog, when clicked outside the dialog? Unfortunately disableBackdropClick has been removed
Hey, sure! It depends on the configuration of your Dialog so you can handle the closing events however you want. The @mui provides the reason for closing in the onClose callback.
constDialogWithoutBackdropClick: React.FC<DialogProps>=({ onClose, ...otherProps})=>{consthandleClose=(event: {},reason: 'backdropClick'|'escapeKeyDown')=>{// Backdrop click is blocked. Don't forget to make a workaround to close the Dialog :)if(reason!=='backdropClick'){onClose?.(event,reason);}};return(<DialogonClose={handleClose}{...otherProps}><DialogTitle>Simple Dialog</DialogTitle></Dialog>);};// Somewhere else<Buttonvariant="contained"onClick={()=>showModal(DialogWithoutBackdropClick)}color="primary">
Click to open
</Button>
Hey, is there a way to disable the closing of an dialog, when clicked outside the dialog?
Unfortunately disableBackdropClick has been removed
The text was updated successfully, but these errors were encountered: