-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[material-ui][Autocomplete] Initial render with a default value set always causes input label to perform the shrink animation #44506
Comments
Hey @ShotSkydiver, thanks for the report. I can confirm this is a bug. |
@ShotSkydiver you can use export default function LimitTags() {
const [showAutocomplete, setShowAutocomplete] = useState(false);
return (
<>
<Button onClick={() => setShowAutocomplete(!showAutocomplete)}>
Show/Hide Autocomplete
</Button>
<Autocomplete
id="render-label"
options={top100Films}
getOptionLabel={(option) => option.title}
value={top100Films[11]}
renderInput={(params) => <TextField {...params} label="limitTags" />}
sx={{
width: "500px",
m: 4,
display: showAutocomplete ? undefined : "none",
}}
/>
</>
);
} |
@yash49 that doesn't work for my use case, I'm building a multi-step form that renders each step separately, so it's that initial render when switching steps that makes the label shrink which is visually jarring |
@ShotSkydiver A similar issue existed in #36548 for <Autocomplete
id="render-label"
options={top100Films}
getOptionLabel={(option) => option.title}
inputValue={top100Films[11].title}
renderInput={(params) => <TextField {...params} label="limitTags" />}
sx={{ width: '500px', m: 4 }}
/>; However, it should also work with |
@ZeeshanTamboli thanks for the further info! Seems like that doesn't work when using an object as the |
@ShotSkydiver Pass the However, you’ll need a controlled Autocomplete using |
@ShotSkydiver I also noticed you are using |
Steps to reproduce
Steps:
Current behavior
When providing a value to Autocomplete, on initial render it'll animate the input label shrinking as if a value was entered after the component was rendered, which gets extra visually annoying when having large groups of autocomplete fields that are contained within Steps or show/hide buttons
Expected behavior
The input label is already shrunk at initial render without any animation, like it is for TextField, Select, etc
Context
N/A
Your environment
npx @mui/envinfo
Search keywords: autocomplete shrink animation initial value
The text was updated successfully, but these errors were encountered: