Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

102
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda