Skip to content

Fix interrupted transitions when changing direction - #3895

Open
dvd233 wants to merge 1 commit into
tailwindlabs:mainfrom
dvd233:fix/react-interrupted-transition-3892
Open

dvd233 wants to merge 1 commit into
tailwindlabs:mainfrom
dvd233:fix/react-interrupted-transition-3892

Conversation

@dvd233

@dvd233 dvd233 commented Sep 10, 2026

Copy link
Copy Markdown

Fixes #3892.

When an enter transition is interrupted by a leave transition, the first
getAnimations() snapshot can still contain the enter transition. Its
finished promise rejects when the browser replaces it, while the replacement
transition continues running. The previous completion guard detected that
replacement but returned without arranging another completion callback, leaving
the element mounted in its transition state.

This change rechecks the element's pending CSS transitions whenever the current
batch settles. It therefore follows replacement transitions and only completes
once none remain.

Test plan

  • Added a deterministic regression test that cancels an enter transition,
    substitutes the reverse transition, and verifies the element unmounts with
    exactly one completion callback.
  • node node_modules/jest/bin/jest.js --config packages/@headlessui-react/jest.config.cjs --maxWorkers=4 --ci --silent
    • 31 suites passed, 1069 tests passed, 57 snapshots passed
  • node node_modules/typescript/bin/tsc -p packages/@headlessui-react/tsconfig.json --noEmit --pretty false
  • node node_modules/prettier/bin/prettier.cjs --check packages/@headlessui-react/CHANGELOG.md packages/@headlessui-react/src/hooks/use-transition.ts packages/@headlessui-react/src/hooks/use-transition.test.tsx
  • React package production build via scripts/build.sh

@vercel

vercel Bot commented Sep 10, 2026

Copy link
Copy Markdown

@dvd233 is attempting to deploy a commit to the Tailwind Labs Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dialog: interrupted enter transition deadlocks useTransition (open flip during duration-100 enter)

1 participant