Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

103
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda