Skip to content

Modal inside modal: closing the first modal closes the second #68

@vicjune

Description

@vicjune
const FirstModal = ({ closeFirstModal }) => {
  const [openSecondModal] = useModal(() => <div>Second modal</div>);

  return (
    <div
      onClick={() => {
        openSecondModal();

        // This closes the second modal as well but it should not
        closeFirstModal();
      }}
    >
      First modal
    </div>
  );
};

const Page = () => {
  const [openFirstModal, closeFirstModal] = useModal(() => (
    <FirstModal closeFirstModal={closeFirstModal} />
  ));

  return <div onClick={openFirstModal}>Click me</div>;
};

In this situation, you click on the div Click me -> it displays First modal

Then when you click on the div First modal:

Expected behaviour: It should display Second modal and close FirstModal

What happens: It closes FirstModal and displays Second modal for a fraction of a second before closing it

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions