[FilledInput][material-next] Add FilledInput component#39307
[FilledInput][material-next] Add FilledInput component#39307mj12albert merged 38 commits intomui:masterfrom
Conversation
Netlify deploy preview@mui/material-next: parsed: +0.31% , gzip: +0.94% Bundle size reportDetails of bundle changes (Toolpad) |
c202d8a to
05d05c6
Compare
30a908b to
8e764ab
Compare
fb9afbb to
08e77aa
Compare
3347073 to
51252cf
Compare
51252cf to
1493a04
Compare
packages/mui-material-next/src/FormControl/FormControl.test.tsx
Outdated
Show resolved
Hide resolved
|
|
||
| const RootSlot = slots.root ?? components.Root ?? FilledInputRoot; | ||
| const InputSlot = slots.input ?? components.Input ?? FilledInputInput; | ||
| if (multiline) { |
packages/mui-material-next/src/FilledInput/FilledInput.test.tsx
Outdated
Show resolved
Hide resolved
c362850 to
6c233b2
Compare
| type, | ||
| }, | ||
| externalForwardedProps: other, | ||
| ownerState: ownerState as FilledInputOwnerState & InputBaseOwnerState, |
There was a problem hiding this comment.
Shouldn't FilledInputOwnerState include the InputBaseOwnerState fields? This shouldn't be necessary then.
There was a problem hiding this comment.
There are some common properties, but even more differences as these OwnerStates include their OwnProps which is where the differences are:
(btw the TS error here was also quite intimidating 😂 luckily I found this trick from Joy https://github.com/mui/material-ui/blob/master/packages/mui-joy/src/Menu/Menu.tsx#L156)
|
|
||
| const RootSlot = slots.root ?? components.Root ?? FilledInputRoot; | ||
| const InputSlot = slots.input ?? components.Input ?? FilledInputInput; | ||
| if (multiline) { |
There was a problem hiding this comment.
<InputBase
slots={{ root: Root, input: Input }}
slotProps={{
input: inputProps,
}}
type={type}
multiline={multiline}
{...rootProps}
/>The error you see comes from the fact you're providing the type prop, which makes TS choose the overload with multiline=false. And since the multiline variable can be true | false, TS complains.
It would be nice if we could do
type={multiline ? undefined : type}
multiline={multiline}
but TS isn't that smart, apparently :)
mnajdova
left a comment
There was a problem hiding this comment.
I am ok with making the types flat, however, can we do some runtime warning if the users does not provide multiline, but they provide some of the props that makes sense only if the component rendered is textarea?
|
|
||
| expect(typeof injectedProps.onBlur).to.equal('function'); | ||
| expect(typeof injectedProps.onFocus).to.equal('function'); | ||
| if (injectedProps) { |
There was a problem hiding this comment.
When would this be undefined? Are we accidentally skipping these expect statements?
There was a problem hiding this comment.
@mnajdova Fixed ~ it's not needed, I accidentally left it there while trying to fix some TS issue!
7557cb4 to
1797c40
Compare
Good idea ~ added in 2f6bc51 |
Part of #39052
FormControl.testsandInputBase.tests) to TS, and adoptinguseSlotPropsFilledInput,FormControl, andInputBase: one depends onSelect, the other depends onTextField/experiments/md3/inputsPreview: https://deploy-preview-39307--material-ui.netlify.app/experiments/md3/inputs/