Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
URLInput now always has an ID and accessible label #40310
URLInput now always has an ID and accessible label #40310
Changes from 2 commits
a57c937
002bcc5
748b3f1
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
How necessary is this? Looks like it uses the same variable. I am not understanding what is being set here.
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.
inputProps
does not include theid
prop, it's only in controlProps. I am not exactly sure how renderControl handles these, but I would assume it's handled differently than here.However, if that condition fails and the renderControl call isn't returned, the input does not receive an ID.
controlProps
doesn't actually output the id prop value anywhere onBaseControl
.You can test this by commenting it out and seeing the lack of ID on the input. The intent here was to fix the failure case and be otherwise minimally invasive. I'm not exactly sure what conditions cause renderControl to be falsey or not.
Let me know if you have any other questions.
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.
@talldan I like what I see here but I am still hesitant to approve this as I am not sure about this id thing. Do you know anything about this component? If not, can you request review from someone who might? Overall, I thought we didn't use class components so I am guessing this is one of the first created.
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.
Hi, @iansvo. Thanks for contributing.
I fear that conditionally providing input ID can cause a mismatch when the
renderControl
override is available. Take the example below; the label here will receive ID but not the input field.The
controlProps
andinputProps
allow us to set proper attributes without worrying if ID is there or not.P.S. Can you rebase this branch on top of the current trunk? 🙇
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.
@Mamaduka I think in my original solution I was just trying to be minimally invasive so I didn't really look into that prop very much. I can see from this PR that this was added as a way to conditional override that rendering (also noted for the future!), which your code here shows.
Now that I understand the intent of this the goal here should just be to always pass the
id
prop toinputProps
and we should have coverage for all cases, including the example case you provided.The
inputId
variable is now always present in bothcontrolProps
andinputProps
. Now, a custom render or a default one will always have everything needed to properly set an accessible label.This should be fully compatible with previous implementations since the
controlProps
are unmodified andinputProps
only has something new, which is the same value, etc.I thought about just setting the value in control props and passing it to
inputProps
by reference, but I think this approach will keep the intent and purpose of the code clear.Please review the latest commit and let me know if you have any other thoughts/feedback. Thanks again for bringing this up and helping the solution be more holistic!
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.
Thanks for the update, @iansvo.
The changes look good to me 👍