Repository navigation
Conversation
lord-0011
requested review from
atomiks,
colmtuite,
flaviendelangle,
jjenzz and
michaldudak
as code owners
November 7, 2026 11:44
commit: |
Bundle size
PerformanceNo regressions in 36 benchmarks · ran 4m 06s · details Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6162
When the toast under the pointer is closed with the mouse (its
Toast.Close), the viewport keepsdata-expandedafter the pointer moves away. The stack only collapses after the pointer enters a toast again and leaves.Cause: when the hovered element is removed, the browser sends no
mouseoutfrom the viewport. The next pointer move only dispatches amouseoveron the element now under the pointer, with arelatedTargetReact still manages. React's enter/leave handling waits for a matchingmouseoutthat never comes, soToastViewport'sonMouseLeave(handleMouseLeave) never runs andhoveringstaystrue.Fix: while the viewport is expanded,
ToastViewportlistens formouseoveron the owner document (capture). If the pointer lands outside the viewport whilehoveringis still set, it runs the existinghandleMouseLeave, so the current deferrals still apply (exit transitions, an active touch swipe) and timers resume as before. The listener only exists while the viewport is expanded, andmouseoverfires only when the pointer moves onto a different element. Focus-driven expansion is unaffected because the handler checkshovering.Test: "collapses when the pointer moves away after the hovered toast was closed" in
ToastViewport.test.tsx. It hovers a toast, closes it, then dispatchesmouseoverondocument.body. It fails without the change (data-expandedstill present) and passes with it.Verification:
pnpm test:jsdom --run packages/react/src/toast: 350 passed, 47 skipped.pnpm test:chromium --run packages/react/src/toast/viewport/ToastViewport.test.tsx: 66 passed, 11 skipped.pnpm --filter @base-ui/react typescriptpass.@base-ui/react1.9.0 and real mouse input (Playwright, Chromium), three stacked toasts withtimeout: 0: hover → click Close → move the pointer away left the viewport expanded in 3/3 runs, and collapsed in 3/3 runs with this change. Hover-and-leave without closing a toast collapses in both.The issue also mentions the swipe case. With my setup, swiping the hovered toast away and moving the pointer off collapsed the viewport even before this change, so I couldn't reproduce that part. This PR only covers the close-button case.
AI disclosure: I used an AI coding assistant to help investigate and prepare this change. I reviewed the diff and the test, and checked that the test fails without the fix.