Skip to content

[toast] Fix swipe direction locking for two-axis swipes - #5295

Merged
sai6855 merged 2 commits into
mui:masterfrom
sai6855:toast-dir-fix
Jul 23, 2026
Merged

[toast] Fix swipe direction locking for two-axis swipes#5295
sai6855 merged 2 commits into
mui:masterfrom
sai6855:toast-dir-fix

Conversation

@sai6855

@sai6855 sai6855 commented Jul 21, 2026

Copy link
Copy Markdown
Member

Fix swipe direction locking for two-axis swipes


let candidate: 'up' | 'down' | 'left' | 'right' | undefined;
if (!intendedSwipeDirectionRef.current) {
if (lockedDirection === 'vertical') {

@sai6855 sai6855 Jul 21, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lockedDirection here is refering to it's stale value not the updated one at line 338.

@sai6855 sai6855 added type: bug It doesn't behave as expected. component: toast Changes related to the toast component. labels Jul 21, 2026
@sai6855
sai6855 requested a review from Copilot July 21, 2026 13:39
@pkg-pr-new

pkg-pr-new Bot commented Jul 21, 2026

Copy link
Copy Markdown

commit: 66d133a

@code-infra-dashboard

code-infra-dashboard Bot commented Jul 21, 2026

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+10B(0.00%) 🔺+5B(0.00%)

Details of bundle changes

Performance

Total duration: 1,353.61 ms +94.35 ms(+7.5%) | Renders: 78 (+0) | Paint: 2,099.79 ms +157.87 ms(+8.1%)

Test Duration Renders
Slider mount (300 instances) 146.03 ms 🔺+24.75 ms(+20.4%) 2 (+0)
Dialog mount (300 instances) 68.85 ms 🔺+15.44 ms(+28.9%) 1 (+0)
Combobox open — 500 items 40.07 ms +6.16 ms(+18.2%) 4 (+0)

12 tests within noise — details

Metric alarms

Test Metric Change
Dialog mount (300 instances) bench:paint 🔺 +21.80 ms
Combobox open — 500 items bench:paint#combobox-open 🔺 +13.30 ms
Combobox open — 500 items bench:paint 🔺 +13.30 ms

Check out the code infra dashboard for more information about this PR.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes swipe direction locking in Toast.Root for two-axis swipes by ensuring the newly determined lock direction is applied immediately within the same pointer-move event (rather than relying on an async state update).

Changes:

  • Resolve and use a local resolvedLockedDirection to avoid stale lockedDirection state during the first “real swipe” move.
  • Add a regression test covering two-axis swipe locking behavior on the first move that crosses the drag threshold.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/react/src/toast/root/ToastRoot.tsx Applies the computed axis lock immediately in the move handler to prevent the first post-threshold move from affecting both axes.
packages/react/src/toast/root/ToastRoot.test.tsx Adds a regression test asserting movement is constrained to a single axis on the first qualifying two-axis swipe move.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@netlify

netlify Bot commented Jul 21, 2026

Copy link
Copy Markdown

Deploy Preview for base-ui ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 66d133a
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a5f775c908a070008943dcd
😎 Deploy Preview https://deploy-preview-5295--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@sai6855
sai6855 marked this pull request as ready for review July 21, 2026 13:42
@sai6855
sai6855 merged commit bf2e527 into mui:master Jul 23, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: toast Changes related to the toast component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants