Skip to content

[number field] Remove event.isTrusted - #3920

Merged
atomiks merged 1 commit into
mui:masterfrom
atomiks:atomiks/replace-is-trusted
Feb 2, 2026
Merged

atomiks merged 1 commit into
mui:masterfrom
atomiks:atomiks/replace-is-trusted

Conversation

@atomiks

@atomiks atomiks commented Feb 1, 2026

Copy link
Copy Markdown
Contributor

Simplifies testing in JSDOM env.

Codex review:

Behavior‑wise, it mattered mostly for non‑trusted change events (tests and any code that manually dispatches change events). Those used to be blocked from showing partial/invalid input; now they’re allowed (but onValueChange still only fires for parseable values).
For real users in browsers, the UX is effectively the same (they already hit the "trusted" path).
So the practical impact is: more predictable in tests and more permissive for programmatic events; the numeric value still won’t change unless parseable.

@atomiks atomiks added component: number field Changes related to the number field component. type: bug It doesn't behave as expected. labels Feb 1, 2026
@pkg-pr-new

pkg-pr-new Bot commented Feb 1, 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@3920
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@3920
    

commit: 392de23

@mui-bot

mui-bot commented Feb 1, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react ▼-95B(-0.02%) ▼-30B(-0.02%)

Details of bundle changes


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

@netlify

netlify Bot commented Feb 1, 2026

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 392de23
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/697fafb8ce276400080ac2b2
😎 Deploy Preview https://deploy-preview-3920--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 1, 2026 19:59
@greptile-apps

greptile-apps Bot commented Feb 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

This PR removes the event.isTrusted check from the NumberField input's onChange handler, unifying the behavior for both trusted (user-initiated) and non-trusted (programmatic/test) events.

Key changes:

  • Previously, trusted events would update inputValue immediately and fire onValueChange for parseable values, while non-trusted events would only update inputValue if parseable
  • Now, both paths follow the same logic: always update inputValue, then fire onValueChange only if parseable
  • This makes testing in JSDOM environments more predictable, as programmatic change events now display partial/invalid input (like ".") in the field
  • User experience in real browsers remains unchanged since they were already using the "trusted" path
  • The numeric value still only updates when the input is parseable, maintaining data integrity

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change is a straightforward simplification that removes unnecessary branching logic. The unified code path is well-tested, and the behavior change only affects non-trusted events (tests and programmatic changes) while preserving the user experience in browsers. The test update correctly validates the new behavior.
  • No files require special attention

Important Files Changed

Filename Overview
packages/react/src/number-field/input/NumberFieldInput.tsx Removed event.isTrusted gate to unify trusted and non-trusted event handling, simplifying test behavior
packages/react/src/number-field/root/NumberFieldRoot.test.tsx Updated test to run in JSDOM and verify that invalid input displays correctly but doesn't trigger value commit

@atomiks
atomiks merged commit 9494870 into mui:master Feb 2, 2026
9 checks passed
@atomiks
atomiks deleted the atomiks/replace-is-trusted branch February 2, 2026 07:32
@coderabbitai coderabbitai Bot mentioned this pull request Aug 12, 2026
5 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants