Skip to content
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

Merged
merged 3 commits into from
Mar 25, 2022

Conversation

thatblindgeye
Copy link
Contributor

@thatblindgeye thatblindgeye commented Mar 18, 2022

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 for menuAppendTo 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 utilizing document.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:

@patternfly-build
Copy link
Contributor

patternfly-build commented Mar 18, 2022

Copy link
Contributor

@nicolethoen nicolethoen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is well done!

How do @mcarrano and @tlabaj feel about the inclusion of an example with 'improper' tab order?

I think it's a powerful demonstration and teaching tool. But I can understand if there are hesitations.

Copy link
Contributor

@wise-king-sullyman wise-king-sullyman left a 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!

@mcarrano
Copy link
Member

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).
Copy link
Contributor

@tlabaj tlabaj Mar 25, 2022

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.

Copy link
Contributor

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)."

Copy link
Contributor

@tlabaj tlabaj left a 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).
Copy link
Contributor

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)."

Copy link
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@tlabaj tlabaj merged commit 6f62e9d into patternfly:main Mar 25, 2022
@patternfly-build
Copy link
Contributor

Your changes have been released in:

  • eslint-plugin-patternfly-react@4.41.4
  • @patternfly/react-catalog-view-extension@4.53.4
  • @patternfly/react-charts@6.55.4
  • @patternfly/react-code-editor@4.43.4
  • @patternfly/react-console@4.53.4
  • @patternfly/react-core@4.202.4
  • @patternfly/react-docs@5.63.4
  • @patternfly/react-icons@4.53.4
  • @patternfly/react-inline-edit-extension@4.47.4
  • demo-app-ts@4.162.4
  • @patternfly/react-integration@4.164.4
  • @patternfly/react-log-viewer@4.47.4
  • @patternfly/react-styles@4.52.4
  • @patternfly/react-table@4.71.4
  • @patternfly/react-tokens@4.54.4
  • @patternfly/react-topology@4.49.4
  • @patternfly/react-virtualized-extension@4.49.4
  • transformer-cjs-imports@4.40.4

Thanks for your contribution! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Select menu document body example doesn't work with a screen reader
8 participants