Skip to content

Commit

Permalink
[FormControl] Fix filled when value is set through inputProps (#3…
Browse files Browse the repository at this point in the history
  • Loading branch information
sai6855 authored Apr 18, 2023
1 parent d14d288 commit 7001e72
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/mui-material/src/FormControl/FormControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const FormControl = React.forwardRef(function FormControl(inProps, ref) {
return;
}

if (isFilled(child.props, true)) {
if (isFilled(child.props, true) || isFilled(child.props.inputProps, true)) {
initialFilled = true;
}
});
Expand Down
11 changes: 11 additions & 0 deletions packages/mui-material/src/FormControl/FormControl.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,17 @@ describe('<FormControl />', () => {
expect(readContext.args[0][0]).to.have.property('filled', true);
});

it('should be filled when a value is set through inputProps', () => {
const readContext = spy();
render(
<FormControl>
<Input inputProps={{ value: 'bar' }} />
<TestComponent contextCallback={readContext} />
</FormControl>,
);
expect(readContext.args[0][0]).to.have.property('filled', true);
});

it('should be filled when a defaultValue is set', () => {
const readContext = spy();
render(
Expand Down

0 comments on commit 7001e72

Please sign in to comment.