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] Add prop for disabling global styles #29213

Merged
merged 7 commits into from
Dec 13, 2021
1 change: 1 addition & 0 deletions docs/pages/api-docs/input-base.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"componentsProps": { "type": { "name": "object" }, "default": "{}" },
"defaultValue": { "type": { "name": "any" } },
"disabled": { "type": { "name": "bool" } },
"disableInjectingGlobalStyles": { "type": { "name": "bool" } },
"endAdornment": { "type": { "name": "node" } },
"error": { "type": { "name": "bool" } },
"fullWidth": { "type": { "name": "bool" } },
Expand Down
1 change: 1 addition & 0 deletions docs/translations/api-docs/input-base/input-base.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"componentsProps": "The props used for each slot inside the Input.",
"defaultValue": "The default value. Use when the component is not controlled.",
"disabled": "If <code>true</code>, the component is disabled. The prop defaults to the value (<code>false</code>) inherited from the parent FormControl component.",
"disableInjectingGlobalStyles": "If <code>true</code>, GlobalStyles for auto-fill will not be injected / removed on mount / unmount.",
"endAdornment": "End <code>InputAdornment</code> for this component.",
"error": "If <code>true</code>, the <code>input</code> will indicate an error. The prop defaults to the value (<code>false</code>) inherited from the parent FormControl component.",
"fullWidth": "If <code>true</code>, the <code>input</code> will take up the full width of its container.",
Expand Down
5 changes: 5 additions & 0 deletions packages/mui-material/src/InputBase/InputBase.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ export interface InputBaseProps
* The prop defaults to the value (`false`) inherited from the parent FormControl component.
*/
disabled?: boolean;
/**
* If `true`, GlobalStyles for auto-fill will not be injected / removed on mount / unmount.
bryan-hunter marked this conversation as resolved.
Show resolved Hide resolved
* @default false
*/
disableInjectingGlobalStyles?: boolean;
/**
* End `InputAdornment` for this component.
*/
Expand Down
8 changes: 7 additions & 1 deletion packages/mui-material/src/InputBase/InputBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ const InputBase = React.forwardRef(function InputBase(inProps, ref) {
componentsProps = {},
defaultValue,
disabled,
disableInjectingGlobalStyles,
endAdornment,
error,
fullWidth = false,
Expand Down Expand Up @@ -493,7 +494,7 @@ const InputBase = React.forwardRef(function InputBase(inProps, ref) {

return (
<React.Fragment>
{inputGlobalStyles}
{!disableInjectingGlobalStyles && inputGlobalStyles}
<Root
{...rootProps}
{...(!isHostComponent(Root) && {
Expand Down Expand Up @@ -607,6 +608,11 @@ InputBase.propTypes /* remove-proptypes */ = {
* The prop defaults to the value (`false`) inherited from the parent FormControl component.
*/
disabled: PropTypes.bool,
/**
* If `true`, GlobalStyles for auto-fill will not be injected / removed on mount / unmount.
* @default false
*/
disableInjectingGlobalStyles: PropTypes.bool,
/**
* End `InputAdornment` for this component.
*/
Expand Down