You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[slider] onChange throws "Failed to construct 'TextEvent': Illegal constructor" when the event can't be re-constructed #49970
Steps:
1.Render a controlled <Slider value={v} onChange={(e, v) => setV(v)} />.
2.Open the page through a browser-isolation product that replays input as TextEvent. We saw it with Menlo Security. The same thing happens whenever the slider’s native event is a type whose constructor is illegal.
3.Move the slider.
new TextEvent('textInput', {}); // TypeError: Failed to construct 'TextEvent': Illegal constructor
useSlider runs new nativeEvent.constructor(nativeEvent.type, nativeEvent) on every change, so any native event of that type makes it throw.
Current behavior
handleChange throws TypeError: Failed to construct 'TextEvent': Illegal constructor before onChange is called. The error is unhandled, the value doesn’t change, and the slider can’t be moved for that user.
Expected behavior
Changing the value should never throw because the event couldn’t be copied. If copying fails, fall back to the original event, or to a plain Event with the overridden target.
Context
useSlider.ts:
const nativeEvent = 'nativeEvent' in event ? event.nativeEvent : event;
const clonedEvent = new (nativeEvent.constructor as typeof Event)(nativeEvent.type, nativeEvent as EventInit);
The same pattern broke Select and Slider in IE11 (#27631), where the fix question was left open. Suggested guard:
let clonedEvent: Event;
try {
clonedEvent = new (nativeEvent.constructor as typeof Event)(nativeEvent.type, nativeEvent as EventInit);
} catch {
clonedEvent = new Event(nativeEvent.type, nativeEvent as EventInit);
}
In production we see this on a map timeline slider, only for users behind Menlo Security browser isolation, on Chrome 156 for Windows. SelectInput has the same copy and may need the same guard.
Your environment
run npx @mui/envinfo in map-widget and paste the output. We use @mui/material 5.16.14, and the copy is unchanged on master.
Activity