Skip to content

[drawer] Fix swipe close flicker#48372

Merged
mj12albert merged 3 commits into
mui:masterfrom
mj12albert:fix-drawer-swipe-close
May 6, 2026
Merged

[drawer] Fix swipe close flicker#48372
mj12albert merged 3 commits into
mui:masterfrom
mj12albert:fix-drawer-swipe-close

Conversation

@mj12albert

@mj12albert mj12albert commented Apr 27, 2026

Copy link
Copy Markdown
Member

@mj12albert mj12albert added the scope: drawer Changes related to the drawer. label Apr 27, 2026
@code-infra-dashboard

code-infra-dashboard Bot commented Apr 27, 2026

Copy link
Copy Markdown

Deploy preview

https://deploy-preview-48372--material-ui.netlify.app/

Bundle size

Bundle Parsed size Gzip size
@mui/material 🔺+770B(+0.15%) 🔺+316B(+0.21%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/private-theming 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes


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

@mj12albert mj12albert added the type: regression A bug, but worse, it used to behave as expected. label Apr 27, 2026
@mj12albert mj12albert marked this pull request as ready for review April 27, 2026 13:36
@mj12albert mj12albert force-pushed the fix-drawer-swipe-close branch 2 times, most recently from 49c795e to ecac3c6 Compare May 1, 2026 09:29
@mj12albert mj12albert force-pushed the fix-drawer-swipe-close branch from ecac3c6 to 954cbf4 Compare May 4, 2026 08:11
@mj12albert mj12albert mentioned this pull request May 6, 2026

@siriwatknp siriwatknp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Two follow-up suggestions to make the cross-file coupling between Slide.handleExit and SwipeableDrawer.setPosition discoverable from both sides.

// Load-bearing: must stay as `translate(x, y)` (not translate3d or translateX/Y).
// Slide.handleExit detects this exact shape to preserve the gesture offset during
// swipe-close — see isGestureTranslate in Slide.js.
const transform = horizontalSwipe
  ? `translate(${rtlTranslateMultiplier * translate}px, 0)`
  : `translate(0, ${rtlTranslateMultiplier * translate}px)`;

Comment on lines +23 to +31
/**
* Detects the two-axis inline transform that SwipeableDrawer writes while the
* user drags. Slide's own hidden positions use translateX/translateY, so this
* lets the exit path preserve only gesture state and keep resetting
* Slide-managed transforms.
*/
function isGestureTranslate(transform) {
return typeof transform === 'string' && /^translate\(.+,\s*.+\)$/.test(transform);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Consider expanding the JSDoc to call out the cross-file coupling — the regex matches SwipeableDrawer.setPosition's exact output, and a future change there (e.g. switching to translate3d) would silently re-introduce the flicker.

Suggested change
/**
* Detects the two-axis inline transform that SwipeableDrawer writes while the
* user drags. Slide's own hidden positions use translateX/translateY, so this
* lets the exit path preserve only gesture state and keep resetting
* Slide-managed transforms.
*/
function isGestureTranslate(transform) {
return typeof transform === 'string' && /^translate\(.+,\s*.+\)$/.test(transform);
}
/**
* Detects the two-axis inline transform that SwipeableDrawer writes while the
* user drags. Slide's own hidden positions use translateX/translateY, so this
* lets the exit path preserve only gesture state and keep resetting
* Slide-managed transforms.
*
* Matches SwipeableDrawer.setPosition's `translate(x, y)` output exactly — keep
* in sync if either side changes the transform serialization.
*/
function isGestureTranslate(transform) {
return typeof transform === 'string' && /^translate\(.+,\s*.+\)$/.test(transform);
}

@siriwatknp siriwatknp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

minor comments

@mj12albert mj12albert enabled auto-merge (squash) May 6, 2026 11:18
@mj12albert

Copy link
Copy Markdown
Member Author

minor comments

Amended the comments, it was overly detailed to begin with, the main point is that it must be kept in sync between the two files

@mj12albert mj12albert merged commit c4bf80f into mui:master May 6, 2026
18 checks passed
@mj12albert mj12albert deleted the fix-drawer-swipe-close branch June 3, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: drawer Changes related to the drawer. type: regression A bug, but worse, it used to behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SwipeableDrawer] Flicker on swipe-to-close: drawer reopens mid-animation before closing

3 participants