Menu

Your closing modal is still eating clicks
📰

Your closing modal is still eating clicks

DEV Community: react·Saurabh Chauhan·about 10 hours ago
#3PnAaYF3
#devtoreact#devto#dev#exit#open
Reading 0:00
15s threshold

You close a modal. The exit animation plays for 200ms. During those 200ms the user clicks the button behind it. Nothing happens.

The modal is fading out, so it looks gone. But it is still in the DOM, still on top, still catching the click.

This is one of the most common bugs in animated overlays, and almost every Framer Motion modal tutorial has it.

Why it happens

AnimatePresence keeps a child mounted after you remove it, so it can play the exit animation. That is the whole point. But "mounted" means the full overlay: the backdrop, the panel, the focus trap, everything.

So for the length of the exit:

the backdrop still covers the page and swallows pointer events

the dialog is still in the tab order, so focus can land in it

screen readers still see a dialog that is already closing

Most code gates interaction on open :

< AnimatePresence > { open && ( < motion . div className = "fixed inset-0 bg-black/40" style = { { pointerEvents : open ?…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.