-
Notifications
You must be signed in to change notification settings - Fork 4.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
TextControl: label not connecting to input if props contains an id #24749
Comments
@truongwp From what I gather, Having said that, it does seem like a relatively simple change, but I think it should be done across all the |
@talldan Sometimes I need to pass my own |
I'd like to work on this, I'll be opening a PR soon // cc @ciampo |
This patch adds support for custom IDs in the `TextControl` component. Currently any passed ID prop is ignored, and a auto-generated value is used instead. --- Resolves WordPress#24749
* Adding support for defined IDs in `TextControl` This patch adds support for custom IDs in the `TextControl` component. Currently any passed ID prop is ignored, and a auto-generated value is used instead. --- Resolves #24749 * Updating tests Changing the test setup for labels to be more `testing-library` idiomatic. * Updating CHANGELOG Adding line item under Enhancements to include `TextControl` changes. * Fixing use of `useInstanceId` Dropping the old `useUniqueId` pattern in favour of the more succinct and complete `useInstanceId` usage.
Describe the bug
If I passed an
id
toTextControl
, the<input>
tag uses that id but the<label>
tag not. It makes the input is not focused when I click to the label.To reproduce
Use this component in an app:
Expected behavior
Both the id of input and label should be
my-custom-id
.Solutions
Add a prop for the label
for
or check if props contains an id, use that id for the label.The text was updated successfully, but these errors were encountered: