-
Notifications
You must be signed in to change notification settings - Fork 376
feat(FormGroupLabelHelp): update markup to match core #10248
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
Conversation
- don't display <div style="display: contents;" with Popovers
|
Preview: https://patternfly-react-pr-10248.surge.sh A11y report: https://patternfly-react-pr-10248-a11y.surge.sh |
| typeof ref === 'object' && ref !== null && 'current' in ref && ref.current !== undefined; | ||
|
|
||
| const handleKeyDown = (event: React.KeyboardEvent<HTMLSpanElement>) => { | ||
| if (event.key === 'Enter' && isMutableRef(buttonRef) && buttonRef.current) { |
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 should include the Space key here. Buttons natively will be triggered via Enter/Space, while anchor elements only by Enter, and radio/checkbox inputs only by Space.
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 insight! I'll include 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 just found out the key for Space is " " and we have some hardcoded "Space" keys in the codebase, so I'll replace them with the KeyTypes.Space constant (or the " " string directly in the examples).
| if ([KeyTypes.Space, KeyTypes.Enter].includes(event.key) && isMutableRef(buttonRef) && buttonRef.current) { | ||
| buttonRef.current.click(); | ||
| } | ||
| }; |
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 little thing. When pressing Space to trigger the popover in this instance, we'll need to prevent the page from scrolling
|
Should there be a codemod written for this change? |
|
@nicolethoen not sure if one will be necessary. The FormGroupLabelHelp was introduced in the v6 branch, and was previously just used to update some examples. Unless we'd want a codemod to check whether |
kmcfaul
left a comment
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, and I do think the addition of the refs to avoid the popper wrapping div is correct. The wrapping div was an alternate method to get the popper functional, but it's not ideal.
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 CSS wise. From the core perspective:
- We could remove the aria-described by for the label help button
Deleted second comment as I missed the label-help component being present in Core
|
Your changes have been released in:
Thanks for your contribution! 🎉 |
What: Closes #10158
I am not sure if the last two commits are necessary. I did them so the
<div style="display: contents;">is not present in the markup and there is no better way to hide it from Popover than by passing both thechildrenand thetriggerRefprop to Popover.