Skip to content

Conversation

@elliottkember
Copy link

@elliottkember elliottkember commented May 28, 2022

Motivation

When a Bottom Sheet is animating in, its currentIndexRef is -1, and is not set to 0 until the animation finishes. This means that if the component is unmounted while it's still opening, the modal sticks around on screen and is uncloseable. This results in a zombie bottom sheet modal that can never be removed! 🧟

To replicate:

  const [showModal, setShowModal] = useState(false);
  useEffect(() => {
    setShowModal(true);
    setTimeout(() => {
      setShowModal(false);
    }, 200);
  }, []);

...

{showModal && <BottomSheetPullUp />}

Changes:

  • adds an animatingRef which tracks the status of the component's entry animation.
  • checks this animatingRef when minimizing the modal
  • animatingRef is initialized as false animateOnMount is set to false!
  • uses onAnimate to set animatingRef = true when animating

@github-actions
Copy link

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@elliottkember
Copy link
Author

elliottkember commented Jul 8, 2022

I think this is still valid!

@iqorlobanov
Copy link

Fixed here: #2564

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants