A BaseInputTemplate of your own must pass inputMode and pattern to the input
Detect
- In your code: a
BaseInputTemplateof your own that hands the result ofgetBaseInputProps()orgetInputProps()to a component, such as a design-system input, that doesn't forward unknown props to the native<input>. - On the rendered page: a
number/integerfield renders as a plain text input with noinputmodeorpattern, and no numeric keyboard on mobile.
Change
InputPropsType has new optional inputMode and pattern members. A template that spreads the input props onto an <input> passes them on already. One that hands them to a component pulls them out and passes them where that component reaches the native input, as @rjsf/mui does through slotProps.htmlInput:
-const { step, min, max } = getBaseInputProps(props);
-<DesignInput step={step} min={min} max={max} />
+const { step, min, max, inputMode, pattern } = getBaseInputProps(props);
+<DesignInput step={step} min={min} max={max} inputProps={{ inputMode, pattern }} />
DesignInput and its inputProps stand in for your component's own way of reaching the native input.
Verify
- A numeric field in your template renders an
<input>withinputmodeandpattern, and a non-numeric value is refused on submit.
Also read: