Skip to content

[slider] Fix change event cloning - #3960

Merged
atomiks merged 3 commits into
mui:masterfrom
atomiks:codex/slider-event-clone
Feb 4, 2026
Merged

atomiks merged 3 commits into
mui:masterfrom
atomiks:codex/slider-event-clone

Conversation

@atomiks

@atomiks atomiks commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

Fixes #3953

@atomiks atomiks added component: slider Changes related to the slider component. type: bug It doesn't behave as expected. labels Feb 4, 2026
@atomiks
atomiks force-pushed the codex/slider-event-clone branch from 55590d0 to e7a77be Compare February 4, 2026 02:13
@netlify

netlify Bot commented Feb 4, 2026

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 55590d0
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6982aaf52b73bc000878ccd5
😎 Deploy Preview https://deploy-preview-3960--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.

@netlify

netlify Bot commented Feb 4, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit c000f2b
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/698316347697b5000703b6da
😎 Deploy Preview https://deploy-preview-3960--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 force-pushed the codex/slider-event-clone branch from 8a57141 to bc276bd Compare February 4, 2026 08:15
@pkg-pr-new

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

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

  • vite-css-base-ui-example

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

commit: c000f2b

@mui-bot

mui-bot commented Feb 4, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+16B(0.00%) 🔺+14B(+0.01%)

Details of bundle changes


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

@atomiks
atomiks marked this pull request as ready for review February 4, 2026 08:19
@greptile-apps

greptile-apps Bot commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

Fixed a critical bug where event cloning incorrectly relied on the global event variable, which can be polluted by third-party code. The fix explicitly references changeDetails.event (the native event from the details object) instead of the implicit global event.

Key Changes:

  • Changed new event.constructor(event.type, event) to new EventConstructor(nativeEvent.type, nativeEvent) where nativeEvent is explicitly changeDetails.event
  • Added proper TypeScript typing for the event constructor
  • Removed the @ts-expect-error comment since the code is now properly typed
  • Added comprehensive regression test that verifies the fix by polluting globalThis.event and ensuring it doesn't interfere with event cloning

Confidence Score: 5/5

  • This PR is safe to merge - it fixes a real bug with proper testing
  • The fix correctly addresses a global variable pollution issue by explicitly referencing the event from the function parameter instead of relying on the implicit global event. The change is well-tested with a comprehensive regression test, properly typed, and follows best practices
  • No files require special attention

Important Files Changed

Filename Overview
packages/react/src/slider/root/SliderRoot.tsx Fixed global event pollution bug by explicitly referencing changeDetails.event instead of relying on the global event variable
packages/react/src/slider/root/SliderRoot.test.tsx Added regression test to verify event cloning doesn't rely on global event variable

import { expect } from 'chai';
import * as React from 'react';
import { spy, stub } from 'sinon';
import { expect as expectVitest, vi } from 'vitest';

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.

Oh I just noticed our AGENTS.md says this

- Tests use `vitest`'s `expect()` and `fn()`, do not assume they have methods of other libraries' APIs. Search existing tests for example usage if unsure. The repository is transitioning from `chai` and `sinon`, prefer `vitest` native functions for all new code.

@atomiks
atomiks merged commit 21e66e8 into mui:master Feb 4, 2026
7 checks passed
@atomiks
atomiks deleted the codex/slider-event-clone branch February 4, 2026 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[slider] Component fails in Shadow DOM: Cannot read properties of undefined (reading 'constructor')

3 participants