New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autocomplete don't get disabled value from FormControl #34418
Comments
Thanks for the feedback. I agree, it is surprising that the other input elements are compatible with the |
Hi @mnajdova ! Pull Request is done ! |
The example in the codesandbox is: <FormControl disabled={true}>
<FormLabel>Custom autocomplete with Input</FormLabel>
<Autocomplete
disablePortal
id="combo-box-demo"
options={top100Films}
sx={{ width: 300 }}
renderInput={(params) => {
console.log(params);
return <Input {...params} />;
}}
/>
</FormControl> The disabled prop is not the only issue, there are many more:
The best fix might be to add documentation on how to use Autocomplete when breaking down the TextField into sub-components. As far as I know, it needs to be: <Autocomplete
disabled={true}
id="combo-box-demo"
options={top100Films}
sx={{ width: 300 }}
renderInput={({ InputProps, inputProps, InputLabelProps, ...params}) => {
return (
<FormControl variant="standard" {...params}>
<InputLabel {...InputLabelProps}>Custom autocomplete with Input</InputLabel>
<Input {...InputProps} inputProps={inputProps} />
</FormControl>
);
}}
/> for the props propagation to be correct. The autocomplete needs to be rendered as a parent of the input elements for the wiring to be correct. |
@oliviertassinari it's a bit confusing to use FormControl inside the Autocomplete no? <FormControl>
<FormLabel>Classic Input</FormLabel>
<Input />
</FormControl> The So, i should be able to use an <FormControl>
<FormLabel>Autocomplete Input</FormLabel>
<Autocomplete />
</FormControl> |
馃檹 This is what I am looking for. Thanks oliviertassinari! 馃檹
|
Duplicates
Latest version
Steps to reproduce 馃暪
Hello,
I'm trying to customize the Autocomplete component.
I want to use it with a FormControl as I use it with my other custom components.
The FormControl should control the "disabled" and "error" state of the input.
But, with the Autocomplete, the disable prop is not passed to the Autocomplete renderInput.
Here is an example : https://codesandbox.io/s/brave-bird-kv5jcc?file=/demo.tsx
As you can see in the console, the disable prop is equal to false, but true in the FormControl.
Current behavior 馃槸
With the Autocomplete, the disable prop is not passed to the Autocomplete renderInput.
Expected behavior 馃
The FormControl should control the "disabled" state of the input.
Context 馃敠
I want to customize the Autocomplete.
I already customized input
Your environment 馃寧
npx @mui/envinfo
The text was updated successfully, but these errors were encountered: