Skip to content

[number field] Create component from the Base UI equivalent - #49275

Open
silviuaavram wants to merge 122 commits into
mui:masterfrom
silviuaavram:feat/number-field
Open

silviuaavram wants to merge 122 commits into
mui:masterfrom
silviuaavram:feat/number-field

Conversation

@silviuaavram

@silviuaavram silviuaavram commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Closes #48335

Adds a Material UI NumberField powered by Base UI, replacing the documentation-only implementation.

Features

  • Outlined, filled, and standard variants with labels, helper text, sizes, colors, and form states. Unlabeled filled fields match TextField sizing, with hiddenLabel available as an opt-in.
  • Controlled and uncontrolled values, bounds, stepping, locale-aware formatting, keyboard interactions, and optional wheel scrubbing.
  • onValueChange and onValueCommitted callbacks reporting numbers or null.
  • controlsPosition supports end (default), split, stacked, or false. Horizontal controls use −/+ buttons. Stacked controls use chevrons and preserve the input height at larger font sizes.
  • Optional scrubAreaPosition supports start, end, or false, independently of button placement. In the filled split layout, the end scrub handle aligns with the adjacent increment button.
  • Typed slots, utility classes, sx, and MuiNumberField theme customization. Root render and slot render props change elements while preserving styles and behavior.

Base UI component mapping

All Base UI NumberField parts are used.

Base UI part Material slot Integration
Root root Renders through FormControl and owns numeric state, behavior, and form submission.
Group Internal to input Shares the Material input root and supplies role="group" without an extra DOM wrapper.
Input htmlInput Connects Base UI behavior to the visible native input styled by the selected Material input variant.
Increment incrementButton Renders through IconButton, with a plus or upward chevron.
Decrement decrementButton Renders through IconButton, with a minus or downward chevron.
ScrubArea scrubArea Optional drag handle with configurable direction, sensitivity, content, and rendering.
ScrubAreaCursor scrubAreaCursor Styled cursor rendered in a portal during scrubbing.

Material-only slots provide InputLabel, FormHelperText, and the InputAdornment wrappers for controls and scrubbing. Split controls reuse the controls slot, with ownerState.position identifying each side.

Implementation and suggested review order

Files are under packages/mui-material/src/NumberField/.

File Review focus
NumberField.types.ts Public API, variant-specific input props, slot types, and augmentation hooks.
NumberField.tsx Defaults, Base UI delegation, resolved owner state, and slot callback resolution.
NumberFieldRootSlot.tsx FormControl composition, label and helper text associations, and initial filled and adorned state for SSR.
NumberFieldInputSlot.tsx and NumberFieldInputRootSlot.tsx Material input composition, the shared Group and input root, render support, and control and scrub handle placement.
utils/resolveInputProps.ts Input prop precedence and handling of name before Base UI composes native handlers and refs.
NumberFieldButtonSlot.tsx Button availability, handler and ref composition, and prevention of duplicate non-native keyboard activation.

Base UI owns numeric behavior. The visible input displays formatted text, while public values remain numeric or null. Set name directly on NumberField to submit the unformatted value once. For example, a field displaying €5.00 submits "5". Both input slots ignore name, with a development warning when only a slot supplies it.

Resolved disabled, read-only, and required states stay aligned across both layers. The forwarded ref targets the FormControl root, and inputRef targets the visible input.

Shared changes

  • Adds @base-ui/react@^1.9.0 as a dependency with deep imports.
  • Registers component exports, theme types, utility classes, and generated API documentation.
  • Adds localized accessible labels for the stepper buttons and a localized role description for the input to the Material UI locale bundles.

Documentation and validation

Replaces the docs-only implementation with 18 demos covering variants, formatting, constraints, control placement, scrubbing, adornments, forms, rendering, and theme customization.

Tests cover Material and Base UI integration, including conformance, prop precedence, event and ref wiring, state, scrubbing, form submission, SSR, and public types.

The visual regression suite captures all 18 demos. Four additional fixtures cover empty fields, unlabeled filled fields alongside TextField, stacked controls at a larger root font size, and filled split controls with an end scrub handle. All 22 NumberField visual regression cases passed locally.

Validated unit and Chromium/Firefox suites, source and docs types, module augmentation, the package build, lint, and formatting.

Uncontrolled fields do not yet support native form reset. The docs demonstrate restoring a controlled value through onReset. Base UI #1346

Base UI renders a visually hidden native input immediately after the field root, which affects selectors such as :last-child. The anatomy docs recommend gap on the parent for spacing adjacent fields. Base UI follow-up

Documentation preview

@silviuaavram silviuaavram self-assigned this Oct 1, 2026
@silviuaavram silviuaavram added type: new feature Expand the scope of the product to solve a new problem. scope: number field Changes related to the number field. labels Oct 1, 2026
@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Oct 1, 2026
@code-infra-dashboard

code-infra-dashboard Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Deploy preview

Bundle size

Bundle Parsed size Gzip size
@mui/material 🔺+47.4KB(+8.30%) 🔺+16.6KB(+10.17%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/private-theming 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Performance

No regressions in 32 benchmarks · precise to ±6.2% (±11.5% at worst) · ran 2m 30s · details


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

@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Oct 5, 2026
@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Oct 13, 2026
@github-actions github-actions Bot added PR: out-of-date The pull request has merge conflicts and can't be merged. and removed PR: out-of-date The pull request has merge conflicts and can't be merged. labels Oct 27, 2026
@github-actions github-actions Bot added PR: out-of-date The pull request has merge conflicts and can't be merged. and removed PR: out-of-date The pull request has merge conflicts and can't be merged. labels Oct 31, 2026
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 3, 2026
@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 5, 2026
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 5, 2026
@silviuaavram
silviuaavram marked this pull request as ready for review November 5, 2026 16:14
Copilot AI balanced review requested due to automatic review settings November 5, 2026 16:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The color and size PropTypes validators reject supported custom values, causing development warnings on React versions that check PropTypes.

2 open issues
1 file not reviewed
  • pnpm-lock.yaml: Generated file
What changed in this PR

Promotes the documentation’s NumberField example into a public Material UI component, addressing #48335. It combines Base UI numeric behavior with Material inputs, form styling, and customization APIs.

Changes:

  • Adds NumberField with three variants, numeric formatting, stepping, scrubbing, typed slots, and theme integration.
  • Replaces copy-and-paste implementations with component demos and generated API documentation.
  • Adds public-type and augmentation checks, adapts documentation tests, and coordinates ButtonBase keyboard cancellation with Base UI.
File Description
test/​moduleAugmentation/​material/​numberFieldCustomProps.tsconfig.json Isolates augmentation checks.
test/​moduleAugmentation/​material/​numberFieldCustomProps.spec.tsx Checks custom props, slots, and theme types.
test/​e2e-website/​demo-docs-production.spec.ts Moves multi-file demo checks to Autocomplete.
pnpm-lock.yaml Records the Material package’s Base UI dependency.
packages/​mui-material/​src/​styles/​props.ts Registers NumberField theme prop types.
packages/​mui-material/​src/​styles/​overrides.ts Registers NumberField style override keys.
packages/​mui-material/​src/​styles/​components.ts Adds NumberField theme configuration.
packages/​mui-material/​src/​NumberField/​utils/​useUtilityClasses.ts Composes NumberField utility classes.
packages/​mui-material/​src/​NumberField/​utils/​resolveInputProps.ts Resolves native prop precedence before merging.
packages/​mui-material/​src/​NumberField/​utils/​index.ts Exports internal helpers.
packages/​mui-material/​src/​NumberField/​utils/​getControlElements.tsx Places controls in input adornments.
packages/​mui-material/​src/​NumberField/​NumberFieldRootSlot.tsx Composes form structure and initial label state.
packages/​mui-material/​src/​NumberField/​NumberFieldInputSlot.tsx Integrates Material inputs, controls, and scrubbing.
packages/​mui-material/​src/​NumberField/​numberFieldClasses.ts Defines public utility classes.
packages/​mui-material/​src/​NumberField/​NumberFieldButtonSlot.tsx Merges button behavior, refs, and state.
packages/​mui-material/​src/​NumberField/​NumberField.types.ts Defines public props and slot types.
packages/​mui-material/​src/​NumberField/​NumberField.tsx Implements the public component.
packages/​mui-material/​src/​NumberField/​NumberField.spec.tsx Checks public TypeScript contracts.
packages/​mui-material/​src/​NumberField/​index.ts Exports component, types, and classes.
packages/​mui-material/​src/​internal/​svg-icons/​Remove.tsx Adds the decrement icon.
packages/​mui-material/​src/​internal/​svg-icons/​OpenInFull.tsx Adds the scrub cursor icon.
packages/​mui-material/​src/​internal/​svg-icons/​ImportExport.tsx Adds the scrub handle icon.
packages/​mui-material/​src/​InputAdornment/​InputAdornment.d.ts Adds a NumberField demo documentation link.
packages/​mui-material/​src/​Input/​Input.d.ts Adds a NumberField demo documentation link.
packages/​mui-material/​src/​index.js Exports NumberField from the package.
packages/​mui-material/​src/​index.d.ts Exports NumberField declarations.
packages/​mui-material/​src/​FormLabel/​FormLabel.d.ts Removes the obsolete demo documentation link.
packages/​mui-material/​src/​FilledInput/​FilledInput.d.ts Adds a NumberField demo documentation link.
packages/​mui-material/​src/​ButtonBase/​useButtonBase.ts Honors Base UI keyboard-handler cancellation.
packages/​mui-material/​src/​Button/​Button.d.ts Removes the obsolete demo documentation link.
packages/​mui-material/​package.json Adds Base UI and the NumberField entry point.
docs/​translations/​api-docs/​number-field/​number-field.json Adds API descriptions.
docs/​public/​static/​error-codes.json Registers the invalid control-position error.
docs/​pages/​material-ui/​api/​number-field.json Adds generated API metadata.
docs/​pages/​material-ui/​api/​number-field.js Adds the API page.
docs/​pages/​material-ui/​api/​input.json Adds the NumberField demo link.
docs/​pages/​material-ui/​api/​input-adornment.json Adds the NumberField demo link.
docs/​pages/​material-ui/​api/​form-label.json Removes the obsolete demo link.
docs/​pages/​material-ui/​api/​filled-input.json Adds the NumberField demo link.
docs/​pages/​material-ui/​api/​button.json Removes the obsolete demo link.
docs/​pages/​experiments/​number-field.tsx Adds a manual integration playground.
docs/​data/​material/​pagesApi.js Registers the NumberField API route.
docs/​data/​material/​components/​number-field/​number-field.md Documents the component and customization APIs.
docs/​data/​material/​components/​number-field/​demos/​validation/​ValidationNumberField.tsx Demonstrates controlled validation.
docs/​data/​material/​components/​number-field/​demos/​validation/​index.ts Registers the validation demo.
docs/​data/​material/​components/​number-field/​demos/​validation/​client.ts Adds its client boundary.
docs/​data/​material/​components/​number-field/​demos/​theme/​NumberFieldTheme.tsx Demonstrates theme defaults and overrides.
docs/​data/​material/​components/​number-field/​demos/​theme/​index.ts Registers the theme demo.
docs/​data/​material/​components/​number-field/​demos/​theme/​client.ts Adds its client boundary.
docs/​data/​material/​components/​number-field/​demos/​steps/​NumberFieldSteps.tsx Demonstrates steps, modifiers, and snapping.
docs/​data/​material/​components/​number-field/​demos/​steps/​index.ts Registers the stepping demo.
docs/​data/​material/​components/​number-field/​demos/​steps/​client.ts Adds its client boundary.
docs/​data/​material/​components/​number-field/​demos/​state/​NumberFieldState.tsx Demonstrates values and commit callbacks.
docs/​data/​material/​components/​number-field/​demos/​state/​index.ts Registers the state demo.
docs/​data/​material/​components/​number-field/​demos/​state/​client.ts Adds its client boundary.
docs/​data/​material/​components/​number-field/​demos/​stacked-controls/​StackedNumberField.tsx Demonstrates stacked chevron controls.
docs/​data/​material/​components/​number-field/​demos/​stacked-controls/​index.ts Registers the stacked-controls demo.
docs/​data/​material/​components/​number-field/​demos/​stacked-controls/​client.ts Adds its client boundary.
docs/​data/​material/​components/​number-field/​demos/​spinner-demo/​SpinnerDemo.tsx Rebuilds the spinner using NumberField.
docs/​data/​material/​components/​number-field/​demos/​spinner-demo/​NumberSpinner.tsx Removes the standalone spinner implementation.
docs/​data/​material/​components/​number-field/​demos/​sizes/​NumberFieldSizes.tsx Demonstrates sizes across variants.
docs/​data/​material/​components/​number-field/​demos/​sizes/​index.ts Registers the sizes demo.
docs/​data/​material/​components/​number-field/​demos/​sizes/​client.ts Adds its client boundary.
docs/​data/​material/​components/​number-field/​demos/​scrub-area-placement/​NumberFieldScrubAreaPlacement.tsx Demonstrates independent handle placement.
docs/​data/​material/​components/​number-field/​demos/​scrub-area-placement/​index.ts Registers the placement demo.
docs/​data/​material/​components/​number-field/​demos/​scrub-area-placement/​client.ts Adds its client boundary.
docs/​data/​material/​components/​number-field/​demos/​scrub-area-options/​NumberFieldScrubAreaOptions.tsx Demonstrates drag direction and sensitivity.
docs/​data/​material/​components/​number-field/​demos/​scrub-area-options/​index.ts Registers the scrub-options demo.
docs/​data/​material/​components/​number-field/​demos/​scrub-area-options/​client.ts Adds its client boundary.
docs/​data/​material/​components/​number-field/​demos/​scrub-area-customization/​index.ts Registers the scrub-customization demo.
docs/​data/​material/​components/​number-field/​demos/​scrub-area-customization/​CustomizedNumberFieldScrubArea.tsx Demonstrates custom handles and cursors.
docs/​data/​material/​components/​number-field/​demos/​scrub-area-customization/​client.ts Adds its client boundary.
docs/​data/​material/​components/​number-field/​demos/​full-width/​index.ts Registers the full-width demo.
docs/​data/​material/​components/​number-field/​demos/​full-width/​FullWidthNumberField.tsx Demonstrates container-width sizing.
docs/​data/​material/​components/​number-field/​demos/​full-width/​client.ts Adds its client boundary.
docs/​data/​material/​components/​number-field/​demos/​format/​index.ts Registers the formatting demo.
docs/​data/​material/​components/​number-field/​demos/​format/​FormattedNumberFields.tsx Demonstrates localized currencies and percentages.
docs/​data/​material/​components/​number-field/​demos/​format/​client.ts Adds its client boundary.
docs/​data/​material/​components/​number-field/​demos/​form/​NumberFieldForm.tsx Demonstrates submission and controlled reset.
docs/​data/​material/​components/​number-field/​demos/​form/​index.ts Registers the form demo.
docs/​data/​material/​components/​number-field/​demos/​form/​client.ts Adds its client boundary.
docs/​data/​material/​components/​number-field/​demos/​form-props/​index.ts Registers the form-props demo.
docs/​data/​material/​components/​number-field/​demos/​form-props/​FormPropsNumberFields.tsx Demonstrates required, disabled, and read-only states.
docs/​data/​material/​components/​number-field/​demos/​form-props/​client.ts Adds its client boundary.
docs/​data/​material/​components/​number-field/​demos/​field-demo/​NumberField.tsx Removes the standalone field implementation.
docs/​data/​material/​components/​number-field/​demos/​field-demo/​index.ts Removes the obsolete demo registration.
docs/​data/​material/​components/​number-field/​demos/​field-demo/​FieldDemo.tsx Removes the previous field demo.
docs/​data/​material/​components/​number-field/​demos/​controls-position/​NumberFieldControlPositions.tsx Demonstrates start, end, and split controls.
docs/​data/​material/​components/​number-field/​demos/​controls-position/​index.ts Registers the control-position demo.
docs/​data/​material/​components/​number-field/​demos/​controls-position/​client.ts Adds its client boundary.
docs/​data/​material/​components/​number-field/​demos/​constraints/​NumberFieldConstraints.tsx Demonstrates bounds and out-of-range input.
docs/​data/​material/​components/​number-field/​demos/​constraints/​index.ts Registers the constraints demo.
docs/​data/​material/​components/​number-field/​demos/​constraints/​client.ts Adds its client boundary.
docs/​data/​material/​components/​number-field/​demos/​color/​NumberFieldColors.tsx Demonstrates focus colors.
docs/​data/​material/​components/​number-field/​demos/​color/​index.ts Registers the color demo.
docs/​data/​material/​components/​number-field/​demos/​color/​client.ts Adds its client boundary.
docs/​data/​material/​components/​number-field/​demos/​basic/​index.ts Registers the basic demo.
docs/​data/​material/​components/​number-field/​demos/​basic/​client.ts Adds its client boundary.
docs/​data/​material/​components/​number-field/​demos/​basic/​BasicNumberFields.tsx Demonstrates the three variants.
docs/​data/​material/​components/​number-field/​demos/​adornments/​NumberFieldAdornments.tsx Demonstrates consumer prefixes and suffixes.
docs/​data/​material/​components/​number-field/​demos/​adornments/​index.ts Registers the adornments demo.
docs/​data/​material/​components/​number-field/​demos/​adornments/​client.ts Simplifies the client-provider export.

Review effort: Balanced

@silviuaavram

Copy link
Copy Markdown
Member Author

@claude review xhigh

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

PR review

This adds a large new public component (NumberField) plus a change to useButtonBase, a hook shared by every Material button. The merge-blocking item is that shared hook change: it teaches useButtonBase to short-circuit keyboard activation on an undocumented baseUIHandlerPrevented flag that Base UI sets on the synthetic event, which affects all ButtonBase consumers and has no test. Also blocking-adjacent: resolveInputProps silently drops the callback form of slotProps.input.slotProps.input, and a generated JSDoc demo list is stale.

Verification limits: @base-ui/react is not installed in this checkout, so Base UI internals (the exact semantics and lifetime of baseUIHandlerPrevented, and whether NumberField.Root's id lands only on the input) could not be confirmed from source — those findings are reasoned from the Material-side code and are labelled accordingly. No tests were run. This review was also capped by the turn budget, so coverage of the ~3600-line test file and the 20 new demo folders is partial.

Bugs (7)

1. 🔴 useButtonBase now keys global keyboard activation off a Base UI–private event flag

Location: packages/mui-material/src/ButtonBase/useButtonBase.ts:105

function isBaseUIHandlerPrevented(event: React.KeyboardEvent<HTMLElement>) {
  return 'baseUIHandlerPrevented' in event && event.baseUIHandlerPrevented === true;
}
if (
  event.target !== event.currentTarget ||
  hasNativeKeyboardActivation() ||
  isBaseUIHandlerPrevented(event)
) {
  return;
}

This is a behavior change in a hook used by Button, IconButton, MenuItem, Tab, ListItemButton, ToggleButton and every other ButtonBase consumer — not just by NumberField. Three concerns compound:

  • Scope. The flag lives on the React synthetic event, which is the same object as it bubbles. Any Base UI handler on a descendant that calls preventBaseUIHandler() marks the event, and an ancestor Material ButtonBase rendered as a non-native button (component="span" / nativeButton={false}) will then skip both event.preventDefault() on Space and the synthesized currentTarget.click() on Enter/Space — so the button stops responding to the keyboard entirely.
  • Coupling. baseUIHandlerPrevented is an internal detail of @base-ui/react's mergeProps, not a documented contract. A rename upstream silently reverts this to the old behavior (double activation) with no type error and no test failure.
  • Semantics. The flag means "an external handler asked Base UI not to run its own handler." Re-reading it as "ButtonBase should not run its handler" is a different statement that happens to produce the right result for the NumberField stepper buttons.

Failure scenario: A consumer composes a Material <IconButton component="span" nativeButton={false}> inside a Base UI component (or passes it as a Base UI render target) where some handler in the chain calls event.preventBaseUIHandler(). Pressing Space or Enter on the button no longer fires onClick, and Space scrolls the page because preventDefault() is skipped. Nothing in NumberField's tests or ButtonBase.test.js / useButtonBase.test.tsx would catch it.

Fix: Keep the shared hook free of Base UI internals. NumberFieldButtonSlot already controls what reaches the button — pass an explicit opt-out (e.g. forward onBeforeKeyDown/a disableKeyboardActivation-style internal prop, or render the stepper with nativeButton so hasNativeKeyboardActivation() already short-circuits) instead of sniffing the event. If the sniff must stay, narrow it to the keydown path only, document the Base UI version the contract comes from, and add useButtonBase/ButtonBase tests that pin both the prevented and non-prevented branches.

2. 🟠 resolveInputProps silently drops slotProps.input.slotProps.input when it is a callback

Location: packages/mui-material/src/NumberField/utils/resolveInputProps.ts:49

const { input: nestedNativeProps, ...remainingMaterialSlotProps } = materialSlotProps ?? {};

// Resolve callback slot props so their returned props participate in precedence.
const selectedNativeProps = resolveComponentProps(effectiveHtmlInputSlotProps, ownerState);

const consumerNativeProps = {
  onKeyDown,
  onKeyUp,
  ...selectedNativeProps,
  ...nestedNativeProps,
};

effectiveHtmlInputSlotProps is run through resolveComponentProps, but nestedNativeProps is spread raw. Material UI's slotProps entries are documented as accepting (ownerState) => props as well as a plain object, and InputBaseProps['slotProps']['input'] is typed that way. Spreading a function yields zero own enumerable properties, so the props vanish — no error, no warning.

Failure scenario:

<NumberField
  slotProps={{
    input: {
      slotProps: { input: (ownerState) => ({ 'aria-label': `Amount (${ownerState.size})` }) },
    },
  }}
/>

The aria-label never reaches the native input, leaving the field unnamed. The equivalent object form works, so the bug looks like a typo in the consumer's code.

Fix: const nestedNativeProps = resolveComponentProps(materialSlotProps?.input, ownerState); (destructuring the key out separately so it is still removed from remainingMaterialSlotProps).

3. 🟠 There is no way to render a NumberField without the stepper buttons

Location: packages/mui-material/src/NumberField/NumberField.types.ts:23

export type ControlsPosition = 'stacked' | 'end' | 'split';

scrubArea accepts 'start' | 'end' | false, where false hides the handle — but controlsPosition has no false. The increment/decrement buttons are always rendered. The most common reason to reach for this component over <TextField type="number"> is the locale-aware formatting, clamping and parsing; many of those users do not want spinners. Today their only escape is slotProps={{ incrementButton: { sx: { display: 'none' } }, decrementButton: { ... } }}, which leaves two buttons in the DOM and keeps the adornment spacing.

Failure scenario: A consumer migrating a currency field from TextField renders <NumberField format={{ style: 'currency', currency: 'EUR' }} /> and gets two unwanted −/+ icon buttons inside the field with no documented way to remove them.

Fix: Accept controlsPosition={false} and skip getControlElements entirely in that case, mirroring scrubArea. This is much cheaper to add now than after the API ships.

4. 🟡 Invalid controlsPosition throws at render instead of degrading

Location: packages/mui-material/src/NumberField/utils/getControlElements.tsx:83

default:
  throw /* minify-error */ new Error(
    `MUI: Cannot position NumberField controls because "controlsPosition" is invalid: ${controlsPosition}. Use "stacked", "end", or "split".`,
  );

Every other Material enum prop (variant, size, color) degrades on an unexpected value. This one takes the whole tree down, in production, from a single typo — and the likeliest source is untyped config rather than JSX: createTheme({ components: { MuiNumberField: { defaultProps: { controlsPosition: 'right' } } } }).

Failure scenario: A JavaScript consumer (or a theme written in JS) sets controlsPosition="right". The app renders a blank screen with minified error 26 instead of a field with default-positioned controls.

Fix: console.error in development and fall back to 'end'; drop the error-code entry if the throw goes away.

5. 🟡 slotProps.htmlInput keyboard handlers silently replace slotProps.input ones

Location: packages/mui-material/src/NumberField/utils/resolveInputProps.ts:39

const { onKeyDown, onKeyUp, ...materialInputProps } = inputProps;
...
const consumerNativeProps = {
  onKeyDown,
  onKeyUp,
  ...selectedNativeProps,
  ...nestedNativeProps,
};

The JSDoc states this precedence deliberately, but lifting the wrapper's handlers to the lowest precedence means passing both slotProps.input.onKeyDown and slotProps.htmlInput.onKeyDown drops the first one entirely. Everywhere else in this file handlers compose (via mergeProps / extractEventHandlers), so the asymmetry is surprising.

Failure scenario: A consumer sets slotProps.input.onKeyDown to intercept Escape and later adds slotProps.htmlInput.onKeyDown for a data-entry shortcut. The Escape handler stops firing with no warning.

Fix: Compose the two rather than overwrite — chain onKeyDown from the wrapper before the native one, the way mergeProps does for the Base UI handlers.

6. ℹ️ Dead variant fallback that disagrees with the component's default

Location: packages/mui-material/src/NumberField/NumberFieldInputSlot.tsx:181

const InputComponent = variantComponent[materialProps.variant ?? 'standard'];

variant is defaulted to 'outlined' in NumberField.tsx:65 and ownerState.variant is typed NumberFieldVariants (non-optional), so ?? 'standard' is unreachable — and if it ever became reachable it would silently pick a different variant than the documented default. Note the neighbouring if (variant === 'outlined') block reads variant directly, so the two disagree. Drop the fallback.

7. ℹ️ labelId uses truthiness while label rendering uses a null check

Location: packages/mui-material/src/NumberField/NumberFieldRootSlot.tsx:51

const labelId = label && id ? `${id}-label` : undefined;
...
const hasLabel = label != null && label !== '';

label={0} satisfies hasLabel but not label &&, so the <InputLabel> renders without an id. There is a test for label={0} (renders zero as label and helper content) and it passes only because nothing currently references labelId — the input is named via htmlFor, not aria-labelledby. Harmless today, but it will bite whoever wires aria-labelledby later. Use hasLabel && id for both.

Tests (4)

1. 🟠 The useButtonBase change has no test anywhere

Location: packages/mui-material/src/ButtonBase/useButtonBase.ts:282

The diff touches a shared hook but leaves packages/mui-material/src/ButtonBase/useButtonBase.test.tsx and packages/mui-material/src/ButtonBase/ButtonBase.test.js untouched. Those files already have the scaffolding (nativeButton={false} renders, keydown/keyup cases) to pin this.

Failure scenario: Base UI renames or stops setting baseUIHandlerPrevented; the early return becomes dead code and the double-activation it was added to prevent returns — and the whole suite stays green. Conversely, if the flag ever appears on an unrelated event, keyboard activation silently breaks for every non-native Material button with no failing test.

Fix: Add two useButtonBase cases — a non-native button whose keydown/keyup event carries baseUIHandlerPrevented: true must not synthesize a click nor call preventDefault() on Space; without the flag it must still do both.

2. 🟡 No assertion that the root element does not share the input's id

Location: packages/mui-material/src/NumberField/NumberField.test.tsx:3105

expect(input).to.have.attribute('id', 'amount');

id is handed to BaseNumberField.Root (NumberField.tsx:104) and to the Material input slot (NumberFieldInputSlot.tsx:431). NumberFieldRootSlot merges Base UI's root props straight onto the FormControl via mergeProps(baseProps, externalHandlers), so if Base UI puts id on its root element the document ends up with two elements sharing it. The SSR test at line 3579 checks uniqueness only across input/label/helper ids, not against the root.

Failure scenario: A duplicate id on the wrapper div and the <input> breaks document.getElementById, label[for] resolution in some AT, and any consumer query by id — and nothing here would catch it.

Fix: Add expect(root).not.to.have.attribute('id', 'amount') (or assert whatever the intended root id is) to the existing labels/helper-text test.

3. 🟡 The controlsPosition error path is untested

Location: packages/mui-material/src/NumberField/utils/getControlElements.tsx:83

A new entry was reserved in docs/public/static/error-codes.json ("26"), but nothing renders a NumberField with an invalid controlsPosition. Error-code entries that are never exercised drift out of sync with the message text they encode.

Failure scenario: The message wording changes and error-codes.json is not regenerated; the minified build then emits a code that maps to stale text.

Fix: Add a case asserting the throw (or, if finding 4 is taken, the dev warning plus the 'end' fallback).

4. 🟡 The documented slotProps precedence rules are only tested in their object form

Location: packages/mui-material/src/NumberField/utils/resolveInputProps.ts:17

The JSDoc specifies a three-level precedence order including slotProps.input.slotProps.input, and slotProps.input.inputProps replacing slotProps.htmlInput "even if undefined". The callback form of the deepest level is the one that is actually broken (finding 2), and there is no test for it.

Failure scenario: Exactly the bug in finding 2 — the callback form drops all props and the suite stays green.

Fix: Parameterize the existing precedence tests over both the object and the (ownerState) => props form for each of the three levels.

Simplifications (3)

1. 🟡 The "drop nullish event handlers" idiom is copy-pasted three times and re-runs every render

Location: packages/mui-material/src/NumberField/utils/resolveInputProps.ts:64

Object.fromEntries(
  Object.entries(consumerNativeProps).filter(
    ([key, value]) => !(/^on[A-Z]/.test(key) && value == null),
  ),
)

The same expression appears at NumberFieldInputSlot.tsx:315 and NumberFieldButtonSlot.tsx:36 (the last one with an extra nativeButton clause). Three literal copies of a subtle rule, each allocating a new object plus an intermediate entries array on every render of every instance, and each with its own cast back to the source type.

Failure scenario: Someone fixes the regex or the nullish check in one place; the other two keep the old behavior, and the "unset handler must not erase Base UI's" invariant silently holds in two of three merge paths.

Fix: One exported helper in NumberField/utils, e.g. omitNullishEventHandlers(props, extraOmit?), used by all three call sites.

2. ℹ️ @base-ui/react becomes a hard runtime dependency of @mui/material

Location: packages/mui-material/package.json:37

"@base-ui/react": "^1.8.0",

This lands in every @mui/material install, including apps that never import NumberField. It is worth calling out explicitly in the PR description and release notes rather than letting it arrive as a lockfile diff — it changes the dependency footprint of the package for all consumers, and it is the first such dependency here. Two smaller points: the range ^1.8.0 is hand-written while the rest of the workspace consumes Base UI through catalog:docs (docs/package.json:22), so the two can drift and resolve to different copies; and it would be worth stating in the PR what the measured bundle delta is for an app that imports only, say, Button.

3. ℹ️ A 1575-line experiments page ships with the feature

Location: docs/pages/experiments/number-field.tsx:1

Experiment pages are normal in this repo, but this one is larger than the component, its tests' conformance block and all 20 demos combined, and it duplicates much of what the demos now cover. Consider trimming it to the cases the public demos do not exercise, or landing it separately so the feature diff stays reviewable.

Docs (4)

1. 🟠 The removal of the Number Field link from Button.d.ts is stale

Location: packages/mui-material/src/Button/Button.d.ts:136

- * - [Number Field](https://next.mui.com/material-ui/react-number-field/)

These "Demos:" lists are generated by pnpm docs:api from the components each demo actually uses, and one of the new demos does use Button:

// docs/data/material/components/number-field/demos/form/NumberFieldForm.tsx:3
import Button from '@mui/material/Button';

So the line should still be there. (The FormLabel.d.ts removal is correct — no new demo imports FormLabel.) This suggests pnpm docs:api was last run against an earlier state of the demos, which means other generated files may be stale too.

Failure scenario: The Button API page loses a valid demo cross-link, and the next unrelated PR that runs pnpm docs:api picks up an unexplained diff in Button.d.ts.

Fix: Re-run pnpm docs:api and commit the result.

2. 🟠 Native form reset is documented as not working, with no tracking link

Location: docs/data/material/components/number-field/number-field.md:156

Native form reset does not currently restore uncontrolled fields to their defaultValue.

Every other Material form control restores on <form> reset. Shipping a form field where the browser's reset button silently does nothing for the uncontrolled case is a real hole, and prose in the middle of a docs page is the weakest place to record it — the component's JSDoc, the defaultValue prop description and the API page all stay silent.

Failure scenario: A consumer builds <form><NumberField name="qty" defaultValue={1} /><button type="reset">Reset</button></form>, the reset leaves the typed value in place, and they file it as a bug because neither the defaultValue nor the form prop docs mention it.

Fix: Link a tracking issue from the docs sentence, and repeat the caveat on the defaultValue prop description so it reaches the API page and IntelliSense.

3. 🟡 The theme overrides section omits two themeable slots

Location: docs/data/material/components/number-field/number-field.md:181

Use MuiNumberField in the theme to set default props or override the root, controls, incrementButton, and decrementButton styles.

NumberFieldScrubArea and NumberFieldScrubAreaCursor are also declared with name: 'MuiNumberField' (NumberFieldInputSlot.tsx:113 and :142) and both have utility classes in numberFieldClasses.ts, so scrubArea and scrubAreaCursor are valid styleOverrides keys. Readers of this sentence will conclude the scrub handle can only be styled per-instance via slotProps.

Fix: Add scrubArea and scrubAreaCursor to the list.

4. ℹ️ MuiNumberField is inserted out of alphabetical order in three registries

Location: packages/mui-material/src/styles/overrides.ts:223

ComponentNameToClassKey places MuiNumberField after MuiPaper; styles/props.ts:213 places it after MuiSnackbarContent; and src/index.js:235 exports it before NoSsr while src/index.d.ts:241 correctly places it after. These files are otherwise strictly alphabetical, so the odd placements will read as accidental to the next person editing them.

Verdict

Request changes — the useButtonBase change alters keyboard activation for every Material button based on an undocumented Base UI event flag and ships with no test, and resolveInputProps silently drops the callback form of a documented slotProps path.


🤖 Review generated with Claude Code · Opus 5 (High) · xhigh review depth · 49 turns · 10m1s · $14.60 · run

@silviuaavram

Copy link
Copy Markdown
Member Author

Addressed each Claude comment apart from #2 and #5 (the slots merging). The rest should be addressed.

@silviuaavram

Copy link
Copy Markdown
Member Author

@claude review xhigh

@silviuaavram

Copy link
Copy Markdown
Member Author

Re-tested on d4980a7 in Chromium, side by side with TextField.

Addressed everything, in separate commits. Also added a few more visual tests for the missing states. PR description updated.

When wrapped in Base UI's `Field.Root`, the slots can also expose `data-valid`, `data-invalid`, `data-touched`, `data-dirty`, `data-filled`, and `data-focused`.
For example, `NumberFieldRootDataAttributes.scrubbing` is the attribute name `data-scrubbing`, which is present while the user drags the scrub handle.

## Anatomy

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.

Please refactor this section to follow the way we describe anatomy in the other components, e.g. https://mui.com/material-ui/react-accordion/#anatomy. I also think we can avoid mentioning Base UI, and focus on all slots the Material UI component has.


See the documentation below for a complete reference to all of the props.
The stepper buttons use `tabIndex={-1}` by default to avoid redundant tab stops.
Keyboard users can adjust the value from the input with the [keyboard shortcuts described above](#stepping).

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.

Suggested change
Keyboard users can adjust the value from the input with the [keyboard shortcuts described above](#stepping).
Keyboard users can adjust the value from the input with the Aup and Down Arrow keys, see more details in the [keyboard shortcuts described above](#stepping).

The buttons remain exposed to screen readers, including on touch devices.

- [`NumberField`](https://base-ui.com/react/components/number-field#api-reference)
NumberField uses [Base UI](https://base-ui.com/react/components/number-field) for numeric input behavior and Material UI components for its appearance.

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.

Why do we have this sentence? Is it intentional for a Base UI Backlink? It seems out of place on the Material UI docs, saying it uses Material UI components is anyway expected. If we really want to emphasize that we use Base UI we could change it to:

Suggested change
NumberField uses [Base UI](https://base-ui.com/react/components/number-field) for numeric input behavior and Material UI components for its appearance.
This component is based on top of the Base UI's [NumberField](https://base-ui.com/react/components/number-field) component.


### Data attributes

NumberField exposes Base UI's state attributes on the following slots.

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.

Ok I will stop mentioning this everywhere, but we should do another pass on this page and focus on explaining the component instead of referencing Base UI everywhere. I assume most of this text comes from the previous docs page where we were using Base UI on the demos directly. Please check the other pages, e.g. TextField and follow that as an example.

@siriwatknp siriwatknp left a comment

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.

Some follow-ups on the implementation, each with a proposed diff.

I checked all the diffs together on top of 16e3f6f1. tsc -p packages/mui-material passes, and the NumberField tests pass in jsdom and Chromium.

const inputStyles = {
variants: [
{
props: ({ ownerState }: { ownerState: NumberFieldOwnerState }) =>

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.

Following up on my earlier comment about typing these variants. The button size fix landed, thanks!

The typing part is still open. The callbacks annotate their parameter, and equality checks such as controlsPosition === 'split' are callbacks instead of object rules.

Could be something like this. memoTheme gets an overload that accepts Interpolation<Props>, and each style annotates its return type:

--- a/packages/mui-material/src/utils/memoTheme.ts
+++ b/packages/mui-material/src/utils/memoTheme.ts
 import { unstable_memoTheme } from '@mui/system';
+import type { CSSInterpolation, Interpolation } from '../styles';
 import type { Theme } from '../styles/createTheme';

-const memoTheme: typeof unstable_memoTheme<Theme> = unstable_memoTheme<Theme>;
+type ThemeProps = { theme: Theme };
+
+function memoTheme(
+  styleFn: (props: ThemeProps) => CSSInterpolation,
+): (props: ThemeProps) => CSSInterpolation;
+function memoTheme<Props>(
+  styleFn: (props: ThemeProps) => Interpolation<Props>,
+): (props: ThemeProps) => Interpolation<Props>;
+function memoTheme(styleFn: (props: ThemeProps) => any) {
+  return unstable_memoTheme<Theme>(styleFn);
+}

 export default memoTheme;
--- a/packages/mui-material/src/NumberField/NumberFieldInputSlot.tsx
+++ b/packages/mui-material/src/NumberField/NumberFieldInputSlot.tsx
 import memoTheme from '../utils/memoTheme';
+import type { Interpolation } from '../styles';

-const inputStyles = {
+const inputStyles: Interpolation<{ ownerState: NumberFieldOwnerState }> = {
   variants: [
     {
-      props: ({ ownerState }: { ownerState: NumberFieldOwnerState }) =>
-        ownerState.controlsPosition === 'split',
+      props: { controlsPosition: 'split' },
       style: {
         [`& > .${inputBaseClasses.input}`]: { textAlign: 'center' },

-const buttonStyles = memoTheme(({ theme }) => ({
+interface NumberFieldButtonStyleProps {
+  ownerState: Omit<NumberFieldOwnerState, 'size'> & { size?: IconButtonProps['size'] | undefined };
+}
+
+const buttonStyles = memoTheme(({ theme }): Interpolation<NumberFieldButtonStyleProps> => ({
   '--NumberField-buttonPadding': '8px',

With the annotation, TypeScript also checks the object rules. For example, { props: { controlsPosition: 'diagonal' } } fails pnpm typescript, while today it compiles.

variants: [
splitEndAdornment,
{
props: ({ ownerState }: { ownerState: NumberFieldOwnerState }) =>

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.

Same as the variant typing in NumberFieldInputSlot.tsx. This check is an equality, so I think it can be an object rule:

--- a/packages/mui-material/src/NumberField/NumberFieldAdornmentSlot.tsx
+++ b/packages/mui-material/src/NumberField/NumberFieldAdornmentSlot.tsx
+import type { Interpolation } from '../styles';

-const NumberFieldControls = styled(InputAdornment, {
-  name: 'MuiNumberField',
-  slot: 'controls',
-})<{ ownerState: NumberFieldOwnerState }>({
+interface NumberFieldAdornmentStyleProps {
+  ownerState: NumberFieldOwnerState & Pick<InputAdornmentProps, 'position'>;
+}
+
+const controlsStyles: Interpolation<NumberFieldAdornmentStyleProps> = {
   variants: [
     splitEndAdornment,
     {
-      props: ({ ownerState }: { ownerState: NumberFieldOwnerState }) =>
-        ownerState.controlsPosition === 'stacked',
+      props: { controlsPosition: 'stacked' },
       style: {
         ...
     },
   ],
-});
+};
+
+const NumberFieldControls = styled(InputAdornment, {
+  name: 'MuiNumberField',
+  slot: 'controls',
+})<{ ownerState: NumberFieldOwnerState }>(controlsStyles);

cursor: 'ew-resize',
variants: [
{
props: ({ ownerState }: { ownerState: NumberFieldOwnerState }) =>

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.

Same here. With the memoTheme overload, these callbacks don't need the parameter annotation, and the data-direction rule gets a type:

--- a/packages/mui-material/src/NumberField/NumberFieldScrubAreaSlot.tsx
+++ b/packages/mui-material/src/NumberField/NumberFieldScrubAreaSlot.tsx
+import type { Interpolation } from '../styles';
+
+interface NumberFieldScrubAreaStyleProps {
+  ownerState: NumberFieldOwnerState;
+  'data-direction'?: 'horizontal' | 'vertical' | undefined;
+}
+
 const NumberFieldScrubArea = styled('span', {
   name: 'MuiNumberField',
   slot: 'scrubArea',
 })<{ ownerState: NumberFieldOwnerState }>(
-  memoTheme(({ theme }) => ({
+  memoTheme(({ theme }): Interpolation<NumberFieldScrubAreaStyleProps> => ({
     ...
     variants: [
       {
-        props: ({ ownerState }: { ownerState: NumberFieldOwnerState }) =>
+        props: ({ ownerState }) =>
           ownerState.scrubAreaPosition === 'start' && ownerState.controlsPosition !== 'split',
         ...
       {
-        props: ({ ownerState }: { ownerState: NumberFieldOwnerState }) =>
-          ownerState.disabled || ownerState.readOnly,
+        props: ({ ownerState }) => ownerState.disabled || ownerState.readOnly,

},
// FormControl's internal component prop preserves its styles and context.
// A replacement slots.root bypasses this render bridge.
internalForwardedProps: ownerState.render

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.

Following up on my earlier nit about the render pass-through. The same block (RenderElement, render, renderState, and the slots check) is repeated in 7 places, so a change to the "slots wins over render" rule has to be made 7 times.

Could be something like one helper next to RenderElement:

--- a/packages/mui-material/src/NumberField/RenderElement.tsx
+++ b/packages/mui-material/src/NumberField/RenderElement.tsx
+export function getRenderElementProps<State>(
+  elementProp: 'component' | 'as',
+  render: useRender.RenderProp<State> | undefined,
+  renderState: State,
+  replacedBySlot = false,
+) {
+  if (!render || replacedBySlot) {
+    return undefined;
+  }
+  return { [elementProp]: RenderElement, render, renderState };
+}
+
 export default RenderElement;
--- a/packages/mui-material/src/NumberField/NumberFieldRootSlot.tsx
+++ b/packages/mui-material/src/NumberField/NumberFieldRootSlot.tsx
-import RenderElement from './RenderElement';
+import { getRenderElementProps } from './RenderElement';

-      internalForwardedProps: ownerState.render
-        ? { component: RenderElement, render: ownerState.render, renderState: baseState }
-        : undefined,
+      internalForwardedProps: getRenderElementProps('component', ownerState.render, baseState),

-            {...(!externalForwardedProps.slots?.inputLabel &&
-              inputLabelRender && {
-                component: RenderElement,
-                render: inputLabelRender,
-                renderState: baseState,
-              })}
+            {...getRenderElementProps(
+              'component',
+              inputLabelRender,
+              baseState,
+              Boolean(externalForwardedProps.slots?.inputLabel),
+            )}

-            {...(!externalForwardedProps.slots?.formHelperText &&
-              formHelperTextRender && {
-                component: RenderElement,
-                render: formHelperTextRender,
-                renderState: baseState,
-              })}
+            {...getRenderElementProps(
+              'component',
+              formHelperTextRender,
+              baseState,
+              Boolean(externalForwardedProps.slots?.formHelperText),
+            )}
The other 3 files
--- a/packages/mui-material/src/NumberField/NumberFieldAdornmentSlot.tsx
+++ b/packages/mui-material/src/NumberField/NumberFieldAdornmentSlot.tsx
-import RenderElement from './RenderElement';
+import { getRenderElementProps } from './RenderElement';

-      {...(render &&
-        !externalForwardedProps.slots?.[slotName] && {
-          component: RenderElement,
-          render,
-          renderState: baseState,
-        })}
+      {...getRenderElementProps(
+        'component',
+        render,
+        baseState,
+        Boolean(externalForwardedProps.slots?.[slotName]),
+      )}
--- a/packages/mui-material/src/NumberField/NumberFieldScrubAreaSlot.tsx
+++ b/packages/mui-material/src/NumberField/NumberFieldScrubAreaSlot.tsx
-import RenderElement from './RenderElement';
+import { getRenderElementProps } from './RenderElement';

-    internalForwardedProps: scrubAreaRender
-      ? { as: RenderElement, render: scrubAreaRender, renderState: baseState }
-      : undefined,
+    internalForwardedProps: getRenderElementProps('as', scrubAreaRender, baseState),

-              {...(!externalForwardedProps.slots?.scrubAreaCursor &&
-                scrubAreaCursorRender && {
-                  as: RenderElement,
-                  render: scrubAreaCursorRender,
-                  renderState: baseState,
-                })}
+              {...getRenderElementProps(
+                'as',
+                scrubAreaCursorRender,
+                baseState,
+                Boolean(externalForwardedProps.slots?.scrubAreaCursor),
+              )}
--- a/packages/mui-material/src/NumberField/NumberFieldButtonSlot.tsx
+++ b/packages/mui-material/src/NumberField/NumberFieldButtonSlot.tsx
-import RenderElement from './RenderElement';
+import { getRenderElementProps } from './RenderElement';

       {...mergedProps}
+      {...getRenderElementProps('component', render, baseState)}
       {...(render && {
-        // Replace IconButton's underlying element while preserving its styles and handlers.
-        component: RenderElement,
-        render,
-        renderState: baseState,
         // The bridge is a custom component, so ButtonBase cannot infer its native-button mode.
         nativeButton: buttonProps.nativeButton ?? true,

await user.keyboard(' ');

expect(screen.getByRole('textbox', { name: 'Amount' })).to.have.value('7');
expect(onValueChange.mock.calls.map(([value]) => value)).to.deep.equal([6, 7]);

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.

It looks missing a check of eventDetails.reason. The docs say both callbacks include details.reason, but no test reads it, so a wrong reason would still pass.

Have you considered one test that maps each interaction to its reason? Something like:

--- a/packages/mui-material/src/NumberField/NumberField.test.tsx
+++ b/packages/mui-material/src/NumberField/NumberField.test.tsx
+  describe('value callbacks', () => {
+    it('reports the Base UI reason for each interaction', async () => {
+      const onValueChange = vi.fn();
+      const onValueCommitted = vi.fn();
+      const { user } = render(
+        <NumberField
+          label="Amount"
+          defaultValue={5}
+          onValueChange={onValueChange}
+          onValueCommitted={onValueCommitted}
+        />,
+      );
+      const input = screen.getByRole('textbox', { name: 'Amount' });
+
+      await user.click(screen.getByRole('button', { name: 'Increase' }));
+      await user.click(screen.getByRole('button', { name: 'Decrease' }));
+      await user.click(input);
+      await user.keyboard('{ArrowUp}');
+      await user.keyboard('7');
+      await user.tab();
+
+      expect(
+        onValueChange.mock.calls.map(([value, details]) => [value, details.reason]),
+      ).to.deep.equal([
+        [6, 'increment-press'],
+        [5, 'decrement-press'],
+        [6, 'keyboard'],
+        [67, 'input-change'],
+      ]);
+      expect(
+        onValueCommitted.mock.calls.map(([value, details]) => [value, details.reason]),
+      ).to.deep.equal([
+        [6, 'increment-press'],
+        [5, 'decrement-press'],
+        [6, 'keyboard'],
+        [67, 'input-blur'],
+      ]);
+    });
+  });

@aarongarciah

Copy link
Copy Markdown
Member

FYI yesterday @silviuaavram and I chatted about exploring:

  • Adding startAdornment / endAdornment props to follow the same model as the upcoming Menu2.Item.
  • Removing scrubAreaAdornment.
  • Using ButtonBase instead of IconButton if it makes more sense from style reutilization perspective.

@silviuaavram

Copy link
Copy Markdown
Member Author

I removed scrubAreaAdornment and exposed startAdornment and endAdornment instead. Check the commit.

I did not replace IconButton with BaseButton. We need to duplicate the style overrides and other things, while the benefits are negligible. Also, Autocomplete also uses IconButton. Let me know if you believe that it's actually worth swapping.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: number field Changes related to the number field. type: new feature Expand the scope of the product to solve a new problem. v10.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[NumberField] Create Material-UI component from the Docs example

6 participants