-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[TextField] Fix classes forward to InputBase #26231
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks!
How can I write tests for this? |
Ideally, we would add in it('should forward classes to InputBase', () => {
const { container } = render(<OutlinedInput error classes={{ error: 'error' }} />);
expect(container.querySelector('.error')).not.to.equal(null);
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the types? #20706 (comment)
docs/pages/api-docs/input.json
Outdated
"globalClasses": { "focused": "Mui-focused", "disabled": "Mui-disabled", "error": "Mui-error" }, | ||
"name": "MuiInput" | ||
}, | ||
"styles": { "classes": [], "globalClasses": {}, "name": null }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this correct? 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in the mean time we may copy the classes from input base and leave a TODO
Let's put the brakes on a bit and don't just merge any PR that comes along, yes?
Something is off with the typings. The changed test and this change in the API docs is an indicator for that. Let's investigate this first before merging something we don't understand.
TODOs are fine only if we know what's wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The purpose of the PR is to forward the classes
props to the InputBase
component so that those can be customized from the other input components FilledInput
, Input
and OutlinedInput
. This is why the types for the classses
are extended (and the tests are no longer throwing as this is now supported). The only problem I see is the buildApi
not recognizing this syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could move iteratively, revert the commits after my proposal and leave a TODO. It's already great that we fix a regression. My proposal was to act on the feedback @m4theushw did a year ago. #20706
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only problem I see is the buildApi not recognizing this syntax.
Thanks for being good faith and ignoring the changed test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The purpose of the PR
Then explain that in the original description not after I point it out. The way PRs are conducted in the recent weeks is not ok. This works for one-off side-projects but I've seen the pain low quality PRs cause. So let's slow down a bit and explain what we're doing. If this isn't possible, then you don't actually understand what a change is doing.
This is why the types for the classses are extended (and the tests are no longer throwing as this is now supported).
Wait, what?
That's definitely not what we want. You shouldn't use props for a variant that you aren't using.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only problem I see is the buildApi not recognizing this syntax.
Thanks for being good faith and ignoring the changed test.Thanks for being good faith and ignoring the changed test.
You cannot just copy the last sentence and get a conclusion. I have stated before that:
The purpose of the PR is to forward the classes props to the InputBase component so that those can be customized from the other input components FilledInput, Input and OutlinedInput. This is why the types for the classses are extended (and the tests are no longer throwing as this is now supported)
Then explain that in the original description not after I point it out.
The PR was initially suppose the change the classes passed, the typings changes were required afterwards, that's why it's not included in the original description.
why the types for the classses are extended (and the tests are no longer throwing as this is now supported).
Wait, what?
That's definitely not what we want. You shouldn't use props for a variant that you aren't using.
I did not just blindly suggest this. If you see what filledProps
is, it has nothing specific to the FilledInput
, the inputAdornedStart
is supported in InputBase, hence in all Input components. It may have been the case that this logic changed over time, and the test now is not up to date.
@eps1lon The ambition of the fix was demoted. It's now only fixing the regression (v4 -> v5) on the forward of the Regarding extending the |
Yep looks ok now after review. In the future, don't blame everything on somebody else on reflex. Thinks usually fail for a reason, not just to block you. |
@arpitBhalla Thanks |
@oliviertassinari Thanks to you too Sir |
Closes #26157