-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Library: Add an explicit label to the search control #51781
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.
LGTM 👍
Do you think we should also update the SearchControl
readme to promote the addition of label
for a11y purposes?
Size Change: +5 B (0%) Total Size: 1.42 MB
ℹ️ View Unchanged
|
@aaronrobertshaw It is already documented as a required prop, so I think it's ok. I noticed there's further discussion here - #51740 |
If it is required, it should be in the code example as well though don't you think? |
5684f57
to
b3350d0
Compare
Oh, yeah, true. I've added a commit to improve the docs. |
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.
One last tiny nit. Sorry 🙂
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 @talldan for the PR. This will improve A11Y for sure. In a follow-up PR, can you fix the typing for label? Label is a type that comes from base-control types and it's optional. I think we should make it required for SearchControl.
/**
* If this property is added, a label will be generated using label property as the content.
*/
label?: ReactNode;
Could not provide exact line, GitHub is going through many changes right now and they broke accessibility for exact line permalinks. 😞
Co-authored-by: Aaron Robertshaw <[email protected]>
4c9c1dd
to
e021758
Compare
I'll make that follow-up 👍 |
* Library: Add an explicit label to the search control * Improve SearchControl label * Fix example spacing Co-authored-by: Aaron Robertshaw <[email protected]> --------- Co-authored-by: Aaron Robertshaw <[email protected]>
What?
Small single line change to add a label prop to the
SearchControl
component in the site editor's library.Why?
Inputs should be labelled and not just rely on placeholder.
While screenreaders (though I'm not sure if all screenreaders) will announce a placeholder, the label is more prominently and consistently announced when the input has text entered.
How?
Specify the label prop. This doesn't change anything visually, but is a good practice to follow for accessibility.
Testing Instructions for Keyboard
Expected: The label 'Search patterns' should be read
Screenshots or screencast
It looks the same.