Skip to content
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

[InputBase] Fix autofill issue #28070

Merged
merged 6 commits into from
Sep 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions packages/material-ui/src/InputBase/InputBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,16 @@ export const InputBaseComponent = styled('input', {
}),
};
});

const inputGlobalStyles = (
<GlobalStyles
styles={{
'@keyframes mui-auto-fill': { from: { display: 'block' } },
'@keyframes mui-auto-fill-cancel': { from: { display: 'block' } },
}}
/>
);

/**
* `InputBase` contains as few styles as possible.
* It aims to be a simple building block for creating an input.
Expand Down Expand Up @@ -483,12 +493,7 @@ const InputBase = React.forwardRef(function InputBase(inProps, ref) {

return (
<React.Fragment>
<GlobalStyles
styles={{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just learned that @babel/plugin-transform-constant-elements deopts mutable props. This unlocks a bunch of optimizations actually since we treat props as immutable all the time. Will investigate in a follow-up.

'@keyframes mui-auto-fill': {},
'@keyframes mui-auto-fill-cancel': {},
}}
/>
{inputGlobalStyles}
<Root
{...rootProps}
{...(!isHostComponent(Root) && {
Expand Down