[drawer] Fix swipe close flicker#48372
Merged
Merged
Conversation
Deploy previewhttps://deploy-preview-48372--material-ui.netlify.app/ Bundle size
Check out the code infra dashboard for more information about this PR. |
49c795e to
ecac3c6
Compare
ecac3c6 to
954cbf4
Compare
Merged
siriwatknp
reviewed
May 6, 2026
Member
There was a problem hiding this comment.
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)`;
siriwatknp
reviewed
May 6, 2026
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); | ||
| } |
Member
There was a problem hiding this comment.
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); | |
| } |
Member
Author
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 |
silviuaavram
approved these changes
May 6, 2026
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 48369 (reproducible in docs)
Preview: https://deploy-preview-48372--material-ui.netlify.app/material-ui/react-drawer/#swipeable