-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Hello. When I tried to use autoFocus, it behaved oddly, both in the case of the mui component and regular HTML's input. When the input is rendered, it looks blank (the first screenshot) even if it has a value, like in the code snippet, and the value appears only after the user's action, like click or key press (the second screenshot after arrow up press).
As far as I understood, this behavior is related to the philosophy of the library, but is it possible to fix it, or do I need to find a workaround?
The base component snippet
import TextField from '@mui/material/TextField';
const NumberField = (props: NumberFieldProps) => {
const formattedInput = useFormattedInput(
intlNumberFormatter({
locales: props.locale,
value: props.value,
onChange: props.onChange,
liveUpdate: true,
...props,
}),
);
const { ref, ...rest } = formattedInput.props;
return <TextField {...restProps} InputProps={{ ...rest, inputRef: ref }} />;
}The usage of the base component
const Usage = () => {
const [value, setValue] = useState<number | null>(12345.67);
return (
<NumberField
autoFocus
label="A number field"
value={value}
onChange={setValue}
/>
)
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels

