@@ -162,6 +162,7 @@ const NumberFieldDecrementButton = styled(IconButton, {
162162} ) ;
163163
164164/**
165+ * The Material input root is Base UI's Group. The native input receives Base UI's editing props.
165166 * @ignore - internal component.
166167 */
167168function NumberFieldInputSlot ( props : NumberFieldInputProps ) {
@@ -175,6 +176,7 @@ function NumberFieldInputSlot(props: NumberFieldInputProps) {
175176 const inputLabelSlotProps = externalForwardedProps . slotProps . inputLabel ;
176177 const inputAdditionalProps : Pick < OutlinedInputProps , 'label' | 'notched' > = { } ;
177178
179+ // The notch takes its width from the label and follows any explicit shrink setting.
178180 if ( variant === 'outlined' ) {
179181 if (
180182 inputLabelSlotProps &&
@@ -196,17 +198,19 @@ function NumberFieldInputSlot(props: NumberFieldInputProps) {
196198
197199 const customInput = externalForwardedProps . slots . input ;
198200 const groupRender = customInput ? undefined : inputRender ;
199- // A local render clears the variant's themed root. An explicit root slot still wins.
201+ // Clear the themed root so Group can use input.render. A root supplied in slot props still wins.
200202 const inputSlots = groupRender
201203 ? { root : undefined , ...materialInputProps . slots }
202204 : materialInputProps . slots ;
203205 const { slots : materialSlots } = useDefaultProps ( {
204206 props : { slots : inputSlots } ,
205- // Read defaults for the selected Material input, rather than NumberField .
207+ // The selected variant can supply its root through theme defaults .
206208 // eslint-disable-next-line mui/material-ui-name-matches-component-name
207209 name : variantName [ variant ] ,
208210 } ) ;
209211 const materialRootComponent = customInput ? undefined : materialSlots ?. root ;
212+ // Use `as` to apply the variant's root styles to Group. When a root slot is supplied,
213+ // Group renders it directly and forwards its props and ref.
210214 const materialSlotProps = customInput
211215 ? materialInputProps . slotProps
212216 : {
@@ -230,7 +234,7 @@ function NumberFieldInputSlot(props: NumberFieldInputProps) {
230234 // An unspecified Base UI validation state must not clear Material's aria-invalid.
231235 const { 'aria-invalid' : ariaInvalid , ...restBaseProps } = baseProps ;
232236
233- // Compose the selected consumer handlers with Base UI; useSlot merges their refs.
237+ // Run consumer handlers first so they can cancel Base UI's action. useSlot merges the refs.
234238 return mergeProps ( ariaInvalid === undefined ? restBaseProps : baseProps , externalHandlers ) ;
235239 } ,
236240 } ) ;
@@ -258,6 +262,7 @@ function NumberFieldInputSlot(props: NumberFieldInputProps) {
258262 } ,
259263 } ) ;
260264
265+ // Base UI checks disabled before stepping. The render prop customizes the Material button.
261266 const {
262267 disabled : decrementButtonDisabled ,
263268 render : decrementButtonRender ,
@@ -279,6 +284,7 @@ function NumberFieldInputSlot(props: NumberFieldInputProps) {
279284 />
280285 ) ;
281286
287+ // Both steppers must target the visible input, whose slot can override the field ID.
282288 const incrementButton = (
283289 < BaseNumberField . Increment
284290 aria-controls = { baseProps . id }
@@ -347,7 +353,8 @@ function NumberFieldInputSlot(props: NumberFieldInputProps) {
347353 const startScrubArea = ownerState . scrubAreaPosition === 'start' && scrubArea ;
348354 const endScrubArea = ownerState . scrubAreaPosition === 'end' && scrubArea ;
349355
350- // Keep the consumer adornment mounted when controls move. An empty fragment would shrink the label.
356+ // Fixed child positions keep consumer adornments mounted when controls move.
357+ // An empty start fragment would still count as an adornment and shrink the label.
351358 const startAdornment =
352359 startControls || startScrubArea || consumerStartAdornment ? (
353360 < React . Fragment >
@@ -396,13 +403,12 @@ function NumberFieldInputSlot(props: NumberFieldInputProps) {
396403 ...( materialRootComponent && { root : NumberFieldInputRootSlot } ) ,
397404 } }
398405 slotProps = { materialSlotProps }
399- // InputBase receives render/state through inputProps; its leaf override
400- // preserves the styled input layer for every variant.
406+ // Use inputComponent so htmlInput.render keeps the variant's input styles.
401407 { ...( htmlInputRender && { inputComponent : RenderElement } ) }
402408 startAdornment = { startAdornment }
403409 endAdornment = { endAdornment }
404410 { ...inputStateProps }
405- // Replacement inputs inherit required from FormControl and supply their own group host .
411+ // A replacement input inherits required from FormControl to keep it off the group element .
406412 required = { customInput ? undefined : ownerState . required }
407413 inputProps = { finalHtmlInputProps }
408414 />
0 commit comments