How to handle "outside" click on Dialog (Modal) with material-ui How to handle "outside" click on Dialog (Modal) with material-ui javascript javascript

How to handle "outside" click on Dialog (Modal) with material-ui


I think what you need is disableBackdropClick passed down to <Modal /> component

<Modal disableBackdropClick />

You can also disable close Dialog on Esc key press with disableEscapeKeyDown prop


disableBackdropClick will not work in Material UI v5.

Dialog API (next)

You can use code from migration guide:

<Dialog  onClose={(event, reason) => {    if (reason !== 'backdropClick') {      onClose(event, reason);    }  }}/>


Just remove the onClose method

  <Dialog     sx={{       position: 'absolute',       left: 300,       top: 35     }}     maxWidth="lg"    open={open}    // onClose={handleClose}   .....