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

[TextField] Fix classes forward to InputBase #26231

Merged
merged 3 commits into from May 16, 2021
Merged

[TextField] Fix classes forward to InputBase #26231

merged 3 commits into from May 16, 2021

Conversation

arpitBhalla
Copy link
Contributor

@arpitBhalla arpitBhalla commented May 10, 2021

Closes #26157

@mui-pr-bot
Copy link

mui-pr-bot commented May 10, 2021

Details of bundle changes (experimental)

Generated by 🚫 dangerJS against d4d7a75

@arpitBhalla arpitBhalla changed the title [TextField] Fix classes is now forwarded correctly in FilledInput [TextField] Fix classes are now forwarded correctly in FilledInput May 10, 2021
@arpitBhalla arpitBhalla changed the title [TextField] Fix classes are now forwarded correctly in FilledInput [TextField] Fix classes forward to InputBase May 10, 2021
Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks!

@arpitBhalla
Copy link
Contributor Author

Great, thanks!

How can I write tests for this?

@mnajdova
Copy link
Member

How can I write tests for this?

Ideally, we would add in OutlinedInput, Input and FilledInput tests for testing the following:

it('should forward classes to InputBase', () => {
  const { container } = render(<OutlinedInput error classes={{ error: 'error' }} />);
  expect(container.querySelector('.error')).not.to.equal(null);
});

@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work component: text field This is the name of the generic UI component, not the React module! labels May 10, 2021
Copy link
Member

@oliviertassinari oliviertassinari left a 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)

"globalClasses": { "focused": "Mui-focused", "disabled": "Mui-disabled", "error": "Mui-error" },
"name": "MuiInput"
},
"styles": { "classes": [], "globalClasses": {}, "name": null },
Copy link
Contributor Author

@arpitBhalla arpitBhalla May 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct? 👀

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, looks like something that is not supported in the buildApi. There is an ongoing effort in #25754 for improving this. cc @eps1lon

I think in the mean time we may copy the classes from input base and leave a TODO

Copy link
Member

@eps1lon eps1lon May 11, 2021

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.

Copy link
Member

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.

Copy link
Member

@oliviertassinari oliviertassinari May 11, 2021

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

Copy link
Member

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.

Copy link
Member

@eps1lon eps1lon May 12, 2021

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.

Copy link
Member

@mnajdova mnajdova May 12, 2021

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 eps1lon added the on hold There is a blocker, we need to wait label May 12, 2021
@oliviertassinari
Copy link
Member

oliviertassinari commented May 15, 2021

@eps1lon The ambition of the fix was demoted. It's now only fixing the regression (v4 -> v5) on the forward of the classes object, from the wrapper to the InputBase component.

Regarding extending the classes types to support more keys, we have #20706. Is seems that we can remove the "on hold" label as the types are no longer impacted. Do you confirm?

@eps1lon
Copy link
Member

eps1lon commented May 15, 2021

Regarding extending the classes types to support more keys, we have #20706. Is seems that we can remove the "on hold" label as the types are no longer impacted.

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.

@eps1lon eps1lon removed the on hold There is a blocker, we need to wait label May 15, 2021
@oliviertassinari oliviertassinari merged commit c5349f1 into mui:next May 16, 2021
@oliviertassinari
Copy link
Member

@arpitBhalla Thanks

@arpitBhalla
Copy link
Contributor Author

arpitBhalla commented May 16, 2021

@oliviertassinari Thanks to you too Sir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: text field This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[TextField] classes is not forwarded correctly on FilledInput
5 participants