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

108
Views
Prevent opening dialog box two times

I have problem with DialogWrapper where is open two times when i clicked on Delete button in Dialog.

There are two events, on first event Dialog is open and when clicked on delete button, it should show progress spinner in button. Once action is finished, dialog is closed.

const [openConfirmDelete, setOpenConfirmDelete] = useState(false);
const [isDeleting, setIsDeleting] = useState(false);

const handleConfirmDelete = () => {
    setOpenConfirmDelete(true);
};

const handleDeleteCompleted = async () => {

    setIsDeleting(true);

    const response = await deleteExpense(fetchExpenseId);

    if(response) {
        setOpenConfirmDelete(false);

        enqueueSnackbar(t("The user account has been removed"), {
        variant: "success",
        });
        setIsDeleting(false)
    }
};

Below code is in JSX where button is clicked.

//For opening Dialog

    <IconButton onClick={() => handleConfirmDelete()} color="primary">
        <DeleteTwoToneIcon fontSize="small" />
    </IconButton>

//Dialog

<DialogWrapper
    open={openConfirmDelete}
    >
    <ButtonError
        onClick={handleDeleteCompleted}
        size="large"
        sx={{
        mx: 1,
        px: 3,
        }}
        variant="contained"
        startIcon={isDeleting ? <CircularProgress size="1rem" /> : null}
        disabled={isDeleting}
    >
        {t("Delete")}
    </ButtonError>
</DialogWrapper>

When I click on the delete button, dialog opens again with Progress bar, but it does not show the progress bar in the first open window.

How to prevent this dialog from opening two times?

about 4 years ago · Juan Pablo Isaza
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!