muibox icon indicating copy to clipboard operation
muibox copied to clipboard

Unable to chained dialogs

Open comxd opened this issue 4 years ago • 2 comments

In case of displaying a new dialog inside a callback, the new dialog is correctly displayed but disappear after component is re-rendered.

import React from "react";
import "./styles.css";
import { useDialog } from "muibox";

export default function App() {
  const dialog = useDialog();
  const handlePrompt = () =>
    dialog
      .prompt({
        message: "Fill your Email and click OK button",
        ok: { text: "OK", color: "primary", variant: "contained" },
        cancel: false
      })
      .then(email => dialog.alert(`Your email: ${email}`))
      .catch(() => {});

  return (
    <div className="App">
      <button onClick={handlePrompt}>Click me</button>
    </div>
  );
}

Codesandbox: https://codesandbox.io/s/muibox-13-bug-chained-dialogs-06lo3

comxd avatar Jun 02 '20 19:06 comxd

For this example, a simple solution is to use setTimeout() before invoke dialog.alert().

chunkai1312 avatar Jun 03 '20 02:06 chunkai1312

For this example, a simple solution is to use setTimeout() before invoke dialog.alert().

Are you sure that's correct approach? This seems like a bug...

Ark-kun avatar Aug 15 '21 23:08 Ark-kun