Skip to content

[drawer][perf] Disable inheritance for swipe CSS vars - #4099

Merged
atomiks merged 2 commits into
mui:masterfrom
atomiks:codex/drawer-disable-css-var-inheritance
Feb 16, 2026
Merged

atomiks merged 2 commits into
mui:masterfrom
atomiks:codex/drawer-disable-css-var-inheritance

Conversation

@atomiks

@atomiks atomiks commented Feb 16, 2026

Copy link
Copy Markdown
Contributor

Similar to Scroll Area: disable the inheritance of the CSS vars to improve performance since they are high-frequency

[drawer] Always disable swipe CSS var inheritance

[drawer] Clarify WebKit inheritance behavior
@atomiks atomiks added component: drawer Changes related to the drawer component. performance labels Feb 16, 2026
@pkg-pr-new

pkg-pr-new Bot commented Feb 16, 2026 •

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/@base-ui/react@4099
    
    pnpm add https://pkg.pr.new/@base-ui/utils@4099
    

commit: ba2f381

@mui-bot

mui-bot commented Feb 16, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+458B(+0.10%) 🔺+181B(+0.12%)

Details of bundle changes


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

@netlify

netlify Bot commented Feb 16, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit ba2f381
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6992f0d3b11e790008a53410
😎 Deploy Preview https://deploy-preview-4099--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@atomiks
atomiks marked this pull request as ready for review February 16, 2026 02:05
@greptile-apps

greptile-apps Bot commented Feb 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR registers five high-frequency drawer swipe CSS custom properties (--drawer-swipe-movement-x, --drawer-swipe-movement-y, --drawer-snap-point-offset, --drawer-swipe-progress, --drawer-swipe-strength) with inherits: false via CSS.registerProperty. This prevents these rapidly-changing values from triggering style recalculations in deep DOM subtrees during swipe gestures.

  • Follows the established pattern from ScrollAreaViewport.tsx, using a module-level boolean flag and a removeCSSVariableInheritance() function called from a layout effect
  • Correctly keeps the WebKit optimization enabled (unlike ScrollArea which skips it) because drawer CSS vars are always set directly on the elements that need them, never relying on inheritance
  • All CSS.registerProperty calls are wrapped in try/catch to handle the "already-registered" case gracefully
  • No issues found — the change is well-scoped and consistent with existing codebase patterns

Confidence Score: 5/5

  • This PR is safe to merge — it's a well-understood performance optimization that follows an established codebase pattern.
  • The change is a straightforward performance optimization using CSS.registerProperty to disable inheritance on high-frequency CSS variables. It follows the exact same pattern already proven in ScrollAreaViewport. All registered variables are set directly on the elements that consume them (verified across DrawerPopup, DrawerBackdrop, DrawerIndent, DrawerSwipeArea, and DrawerViewport), so disabling inheritance introduces no behavioral change. Error handling is correct, browser feature detection is in place, and the WebKit caveat is properly documented and addressed.
  • No files require special attention

Important Files Changed

Filename Overview
packages/react/src/drawer/popup/DrawerPopup.tsx Adds removeCSSVariableInheritance() to register 5 high-frequency swipe CSS variables with inherits: false via CSS.registerProperty, matching the established ScrollArea pattern. All registered vars are set directly on elements via style.setProperty, so disabling inheritance is safe. No issues found.

Last reviewed commit: a758322

@greptile-apps

greptile-apps Bot commented Feb 16, 2026

Copy link
Copy Markdown
Contributor

Automatic reviews are disabled for this repository.

@atomiks
atomiks merged commit c353c9f into mui:master Feb 16, 2026
7 checks passed
@atomiks
atomiks deleted the codex/drawer-disable-css-var-inheritance branch February 16, 2026 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: drawer Changes related to the drawer component. performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants