Skip to content

Commit

Permalink
Add back component prop
Browse files Browse the repository at this point in the history
  • Loading branch information
mj12albert committed Sep 21, 2023
1 parent 8e940b8 commit c380c75
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ describe('<FormControl />', () => {
render,
refInstanceof: window.HTMLDivElement,
muiName: 'MuiFormControl',
testVariantProps: { margin: 'dense' },
slots: {
root: {
expectedClassName: classes.root,
testWithElement: 'fieldset',
},
},
skip: ['componentProp', 'componentsProp'],
testComponentPropWith: 'fieldset',
testVariantProps: { margin: 'dense' },
skip: ['componentsProp'],
}));

describe('initial state', () => {
Expand Down
5 changes: 4 additions & 1 deletion packages/mui-material-next/src/FormControl/FormControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ const FormControl = React.forwardRef(function FormControl<
const {
children,
className,
classes: classesProp,
color = 'primary',
component: ComponentProp = 'div',
disabled = false,
error = false,
focused: visuallyFocused,
Expand Down Expand Up @@ -182,6 +184,7 @@ const FormControl = React.forwardRef(function FormControl<
...props,
classes: props.classes ?? {},
color,
component: ComponentProp,
disabled,
error,
filled,
Expand Down Expand Up @@ -239,7 +242,7 @@ const FormControl = React.forwardRef(function FormControl<
variant,
]);

const Root = slots.root || FormControlRoot;
const Root = slots.root ?? ComponentProp ?? FormControlRoot;
const rootProps = useSlotProps({
elementType: Root,
externalSlotProps: slotProps.root,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ export interface FormControlTypeMap<
export type FormControlProps<
RootComponentType extends React.ElementType = FormControlTypeMap['defaultComponent'],
AdditionalProps = {},
> = OverrideProps<FormControlTypeMap<AdditionalProps, RootComponentType>, RootComponentType>;
> = OverrideProps<FormControlTypeMap<AdditionalProps, RootComponentType>, RootComponentType> & {
component?: React.ElementType;
};

type MaterialYouOwnerStateKeys =
| 'classes'
Expand Down

0 comments on commit c380c75

Please sign in to comment.