-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[InputBase] Pass aria attributes to input #14580
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.
This is a working solution to the immediate problem. However it adds more technical debt to the inputProps
<-> InputProps
ambiguity. Maybe we can remove them and spread excess props in InputBase
to the input
rather than the div
. I don't think many people expect or value the current behavior. For styling we could always use some wrapper class.
@eps1lon Are you suggesting the introducing of a |
I would just omit it for now. Are people actually interested in it? |
@eps1lon I have no idea. Ok, I'm happy with this plan of action. |
@material-ui/core: parsed: -0.19% 😍, gzip: -0.28% 😍 Details of bundle changes.Comparing: eb357a9...a074ad6
|
@eps1lon I have tried the prop spread change from root to input. I'm not 💯% convinced it's a better idea. |
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.
"root component" has nothing to do with to top component but rather where excess props are spread and the root
class is applied.
root component being equal to the top component was incidental.
The breaking change is that the root component is now an input
instead of a div
.
@@ -76,7 +76,12 @@ function testComponentProp(element, getOptions) { | |||
function testPropsSpread(element, getOptions) { | |||
it(`does spread props to the root component`, () => { | |||
// type def in ConformanceOptions | |||
const { classes, inheritComponent, mount } = getOptions(); | |||
const { classes, inheritComponent, mount, propsSpread = true } = getOptions(); |
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 way you would want to implement this is with a skip
option. The current implementation would still create a test report.
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.
Do you mean that we should return earlier (before it()
)?
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 don't understand what you mean by skip.
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.
Use a skip
option to filter
in
The filter should also include testComponentPropWith
so that we can get rid of
https://github.com/mui-org/material-ui/blob/71234113e3d14bcbfe0d3acec3023d219615d74e/packages/material-ui/src/test-utils/describeConformance.js#L57
@@ -41,7 +42,7 @@ describe('<SelectInput />', () => { | |||
|
|||
it('should render a correct top element', () => { | |||
const wrapper = shallow(<SelectInput {...defaultProps} />); | |||
assert.strictEqual(wrapper.name(), 'div'); | |||
assert.strictEqual(wrapper.name(), 'Fragment'); |
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 might as well remove it. The test does not provide any value. Nobody cares what the "top element" is. We don't have any public API about what a "top element" is.
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.
Sure.
@@ -38,6 +38,7 @@ describe('<InputBase />', () => { | |||
classes, | |||
inheritComponent: 'div', | |||
mount, | |||
propsSpread: false, |
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.
That would be a breaking change. I don't understand how this relates to passing through of aria attributes.
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 relation comes from an old comment of you: #14580 (review).
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.
But that's not what I said. I wanted to change to root component from the div
to the input
.
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.
You have introduced a new concept: a top component. So, you would like to keep the current changes but to push them one step further? .root -> .container, .input -> .root?
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.
A few components don't have any top component, like the Tooltip. The component doesn't have any root classes.
@eps1lon It depends on each word definitions. |
In the following, we gonna use your new concept: the top component, it represents the first element in the DOM structure. It might not be present when using a fragment. The root component is where we spread the properties There is one more technicality to take into account, the NativeSelectInput and SelectInput internal components share the same style sheet but have a different DOM & React structure. We can take a few components that are a good illustration of the possible edge cases: Tooltip, ListItem, InputBase, Select, Button. I see two options:
|
I have been using the strategy n°1. so far, with this switch of definitions:
|
@eps1lon So I have two questions, with your definitions:
|
My understanding is that the root element is (currently) defined as the top or outermost element in a component, and the class applied to this was named From the docs:
and: "Any other properties supplied will be spread to the root element Whether that is always intuitive is a different question. I'm not objecting to any particular proposed solution, including a change in terminology if it makes sense. |
To be honest I would prefer to be strict here and not allow any special cases. Every excess prop of My definition "root = whatever we define" gives us more flexibility. Excess props and root class would be applied to the input and the wrapper would just get a |
Hey, added fix for aria attributes being passed to div rather than input.Closes #14555
Solves #11377 (comment)?
Breaking change
The props provided to the Input, FilledInput, OutlinedInput, and InputBase are now spread on the native input element instead of the root element (
div
).This is the behavior most of our users expect. We are not following the root spread convention for hopefully, a more intuitive API. Many people have been complaining about the InputProps vs inputProps difference (different case) #10064. This problem is gone. We will deprecate
inputProps
in v4.1, it's a soft deprecation for now.