-
Notifications
You must be signed in to change notification settings - Fork 357
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
chore(Select): update examples to show different appends #7087
Conversation
Preview: https://patternfly-react-pr-7087.surge.sh A11y report: https://patternfly-react-pr-7087-a11y.surge.sh |
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.
3729556
to
0d1b7ed
Compare
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 really like the side by side comparison of the approaches!
I like this approach, too, @nicolethoen . In the future we may want to consider how we order these examples as this feels stuck in the middle of the page. But that's a larger discussion about making this component documentation more readable/usable, I think. |
### Select menu document body | ||
### Appending document body vs parent | ||
|
||
When passing in a value to the `menuAppendTo` prop on the Select component, passing in `document.body` should be avoided if possible as doing so can cause accessibility issues. These issues can include (but may not be limited to) being unable to enter the contents of the Select options via assistive technologies (like keyboards or screen readers). |
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.
Maybe someone for content can take a quick look at this.
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.
Allison took a look and suggested the following
"Avoid passing in document.body
when passing a value to the menuAppendTo
prop on the Select component, as it can cause accessibility issues. These issues can include, but are not limited to, being unable to enter the contents of the Select options via assistive technologies (like keyboards or screen readers).
Instead append to "parent"
to achieve the same result without sacrificing accessibility.
In this example, while, when the dropdown is opened, both Select variants handle focus management within their dropdown contents the same way, you'll notice a difference when you try pressing the Tab key after selecting an option.
For the document.body
variant, the focus will be placed at the end of the page, since that is where the dropdown content is appended to in the DOM (rather than focus being placed on the second Select variant as one might expect). For the "parent"
variant, however, the focus will be placed on the next tab-able element (the "Toggle JS code" button for the code editor in this case)."
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 other than suggested copy from Allison.
### Select menu document body | ||
### Appending document body vs parent | ||
|
||
When passing in a value to the `menuAppendTo` prop on the Select component, passing in `document.body` should be avoided if possible as doing so can cause accessibility issues. These issues can include (but may not be limited to) being unable to enter the contents of the Select options via assistive technologies (like keyboards or screen readers). |
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.
Allison took a look and suggested the following
"Avoid passing in document.body
when passing a value to the menuAppendTo
prop on the Select component, as it can cause accessibility issues. These issues can include, but are not limited to, being unable to enter the contents of the Select options via assistive technologies (like keyboards or screen readers).
Instead append to "parent"
to achieve the same result without sacrificing accessibility.
In this example, while, when the dropdown is opened, both Select variants handle focus management within their dropdown contents the same way, you'll notice a difference when you try pressing the Tab key after selecting an option.
For the document.body
variant, the focus will be placed at the end of the page, since that is where the dropdown content is appended to in the DOM (rather than focus being placed on the second Select variant as one might expect). For the "parent"
variant, however, the focus will be placed on the next tab-able element (the "Toggle JS code" button for the code editor in this case)."
0d1b7ed
to
8ece963
Compare
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!
Your changes have been released in:
Thanks for your contribution! 🎉 |
What: Closes #6150
While this PR does not actually fix the issue of the Select component appended to
document.body
not working with screen readers, I think the best option instead is utilizing the"parent"
value formenuAppendTo
props across components (if we're able). While it isn't as evident in the updated example (Appending document body vs parent), I think the results are better seen in the below codesandbox link in which I utilized Modals (as I believe this was one of the major reasons for utilizingdocument.body
).I also added some instructions/warnings about appending the Select component to the
document.body
, to help make it clearer why it should be avoided and showing the alternative.Codesandbox: Select inside Modal
Additional issues: