-
Notifications
You must be signed in to change notification settings - Fork 536
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
Adds FormControl's "Auto-Wiring" to SelectPanel v2 Component #4389
Adds FormControl's "Auto-Wiring" to SelectPanel v2 Component #4389
Conversation
🦋 Changeset detectedLatest commit: eacfa7c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@@ -315,7 +328,8 @@ const Panel: React.FC<SelectPanelProps> = ({ | |||
} | |||
|
|||
const SelectPanelButton = React.forwardRef<HTMLButtonElement, ButtonProps>((props, anchorRef) => { | |||
return <Button ref={anchorRef} {...props} /> | |||
const inputProps = useFormControlForwardedProps(props) |
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.
Followed the pattern suggested in this slack thread: https://github.slack.com/archives/CSGAVNZ19/p1709843761424779?thread_ts=1709836721.563139&cid=CSGAVNZ19
Octicon, | ||
Link, | ||
Checkbox, | ||
useFormControlForwardedProps, |
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.
Using the hook recently created by @iansan5653 in this PR: #3632. This hook is also being used in the InlineAutocomplete
draft component:
const inputProps = useFormControlForwardedProps(externalInputProps) |
size-limit 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.
Looks good!
Merging to main is blocked today for another release. I can merge this tomorrow.
Sounds great, thank you! |
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.
🎉
🤔 Overall the approach looks great, but I have concerns about the accessibility implications. If a button's label is set using This is problematic for several reasons:
A potential alternative: What if instead of setting
However there are risks with this approach too: will users be confused by the accessible label of the element changing when the selected value changes? I don't know how this would affect VoiceOver users. It's also possible this could create confusing labels, like if the consumer sets the visible label and the button text to the same value: "Choose a tag: Choose a tag" would be annoying. IMHO, the potential for annoyance is probably outweighed by the potential for totally excluding important context. A third option might be to explore a different On one hand yes, it's an activatable button that opens a panel; but on the other hand it's also an input with a visible current value. Is there a role we can use that would allow us to set both a label and a current value? I think it's worth digging in to this a bit further - maybe in accessibility office hours? |
@iansan5653 thank you for the detailed and thoughtful review. As we use the If that's the case would it either a) be appropriate to change to Alternatively, the 2nd option you propose seems acceptable as well. I'm happy to go to a11y office hours to discuss this further if needed as well. Let me know the next one you're available for. |
Yep, pretty much. While both roles are widgets with accessible names and text content, screen readers intentionally ignore the text content of a button in favor of its accessible name. 99% of the time these two things are identical (because it's not really standard to have a button with an external label), so if a screen reader were to read out both it would be annoying and unnecessary the vast majority of the time .
Unfortunately not. Native browser It's honestly possible that we should consider always giving the |
@iansan5653 that's interesting context. It seems like giving SelectPanel the |
I believe it was mentioned that We do have something else in the works that could act as the middle ground between I'm wondering if we could keep the usage of <label id="label1">SelectPanel within FormControl</label>
<button id="label2" aria-labelledby="label1 label2">Choose a tag</button> This means that the button references both the label and the contents within itself (i.e. "Choose a tag"), making the accessible name: "SelectPanel within FormControl, Choose a tag". This is using multiple We could also change the order so that the current value is announced first (e.g. I'd still recommend running this by the direct Accessibility team, as I may be unaware of any other implications, such as how someone using voice might interact with this control, and Ian's comments around potential confusion with the label. I don't mind following up with them too! |
This is great @iansan5653, thanks for bringing this up! I totally missed it.
This looks perfect! There is a really old discussion that might be helpful to read through: https://github.com/github/primer/discussions/696
This would work nicely! @TylerJDev, Just checking, both of these information should be considered as labels right (not description)?
As Tyler said, it's something still being discussed with our accessibility consultants, we may or may not end up there. It's tricky because SelectPanel also has other elements like filter buttons (that look like tabs). Let's park that for a couple weeks till we can conclude if we're going the combobox route or not. @JeffreyKozik how do you feel about making this change? If you've got other things on your plate, I can help out here! |
@TylerJDev @siddharthkp thanks for providing more details on this issue! I'll take a swing at this change later today, but if I get pulled into other issues and need you to help out here on Monday I'll let you know, thanks @siddharthkp! |
Yup, exactly! If we used a description for one or the other, there's the possibility that it would be ignored by a screen reader (or other AT). |
@siddharthkp if this approach looks suitable to you, I think it's ready to merge 👍 |
It's working as expected now |
Integration tests passed 🎉 https://github.com/github/github/pull/322332 Only tests failing seem related to |
Followup to this conversation in Slack and #4372. Related to https://github.com/github/primer/issues/2396.
Changelog
New
Changed
Made use of the the new useFormControlForwardedProps hook (introduced by #3632) to automatically wire the SelectPanel v2 component to the accessibility and validation provided by the FormControl component it's nested within. If SelectPanel v2 isn't nested within FormControl the hook has no effect.
Within a form the accessible name is now the text within the corresponding FormControl.Label tag and the button itself
Outside of a form the accessible name is still the text within the SelectPanel.Button itself
Removed
Rollout strategy
Testing & Reviewing
Merge checklist