Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

176
Views
Material ui onClose as replacement for disableBackdropClick

Currently I have a dialog

  <Dialog
    open={open}
    data-testid="myTestDialog"
    disableEscapeKeyDown={true}
    disableBackdropClick={true}
  >

From the docs https://material-ui.com/api/dialog/ disableBackdropClick is depreciated and onClose should be used instead but how can I modify the above code to make it work using the new onClose, I am not familiar with this function/signature

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

To use onClose, your variable open needs to be settable. When open is true the dialog is shown and when onClose is called it sets open to false but only when it is not closing because of a background click or escape press.

E.g.

<Dialog
    open={open}
    data-testid="myTestDialog"
    onClose={(event, reason) => {
        if(reason !== 'backdropClick' && reason !== 'escapeKeyDown') {
            // Set 'open' to false, however you would do that with your particular code.
            setOpen(false);
        }
    }
>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!