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

Opening Modal from OverflowMenu, focus is not placed on the Modal's selectorPrimaryFocus #4036

Closed
kinueng opened this issue Sep 19, 2019 · 5 comments · Fixed by #5260
Closed
Labels
severity: 1 https://ibm.biz/carbon-severity type: a11y ♿ version: 9 Issues pertaining to legacy Carbon

Comments

@kinueng
Copy link
Contributor

kinueng commented Sep 19, 2019

When using <OverflowMenu> with a <OverflowMenuItem> that opens a <Modal selectorPrimaryFocus>, the focus is not being placed on the <Modal> but rather the <OverflowMenu> that is in the background.

Environment

Operating system

macOS Mojave Version 10.14.6

Automated testing tool and ruleset

N/A

Browser

Chrome Version 76.0.3809.132 (Official Build) (64-bit)

Automated testing tool and ruleset

Job Access With Speech (JAWS), MacOS VoiceOver

Detailed description

What version of the Carbon Design System are you using?

  • "carbon-components": "9.x"
  • "carbon-components-react": "6.x"

What did you expect to happen?

The <OverflowMenu> items open a <Modal>. When choosing a menu item, the focus should be placed on the modal, specifically the modal's close button. The close button should have focus by specifying <Modal selectorPrimaryFocus='.bx--modal-close'>

What happened instead?

After the <Modal> is opened, the <OverflowMenu> is stealing focus.

What WCAG 2.1 checkpoint does the issue violate?

I do not know the exact WCAG 2.1 violation. When using screen readers, it is misleading to visually impaired users what is on the screen. The screen reader announces the Overflow menu when the screen reader should be reading the opened modal.

Steps to reproduce the issue

  1. Use the tab key to place focus on the ... button (i.e. <OverflowMenu>)
  2. Push Enter key
  3. Use tab key to choose a menu item
  4. Push Enter key
  5. Observe the modal opening and overlaying over the overflow menu button
  6. Observe the focus is placed on the overflow menu button, which is now in the "background"

Additional information

Here is the problem below in my product recorded in a .gif file:
carbon-overflow-modal-focus-demo

NOTE: There is a workaround seen in the gif file. After opening the modal, the user can use the tab key to place focus on the modal x close button. When you recreate the problem, the focus is now placed correctly on the modal close button.

@kinueng kinueng changed the title Opening Modal from an OverflowMenu, the focus is not placed on the Modal selectorPrimaryFocus Opening Modal from OverflowMenu, focus is not placed on the Modal's selectorPrimaryFocus Sep 19, 2019
@gscottj
Copy link

gscottj commented Sep 25, 2019

WCAG 2.1 violation is with respects to Success Criterion 2.4.3 Focus Order
https://www.w3.org/TR/WCAG21/#focus-order
https://www.w3.org/WAI/WCAG21/Understanding/focus-order

@asudoh
Copy link
Contributor

asudoh commented Sep 26, 2019

Workaround: The overflow menu action opening modal with setTimeout(), instead of opening modal synchronously.

@kinueng
Copy link
Contributor Author

kinueng commented Sep 26, 2019

Hello @asudoh,

I was unsuccessful at using setTimeout() as a workaround. Do you have an example showing setTimeout() working as a workaround?


setTimeout() Workaround Attempt

Below is my unsuccessful codesandbox.io attempt at using setTimeout() to delay the modal opening after clicking an overflow menu item. I am assuming the workaround is an attempt to let the <OverflowMenu> focus event happen first and then let the <Modal> focus event happen next to correctly place the focus on the Modal. Is that the workaround’s intent?

https://codesandbox.io/s/codesandbox-sdcsh

Debugging observations

When I put breakpoints in <OverflowMenu> and <Modal> on the product that I work on (https://github.com/kappnav/ui), I am noticing that the modal never runs the logic to process the selectorPrimaryFocus property in https://github.com/carbon-design-system/carbon-components-react/blob/68c30ea43c6502826f1150c67f35bb2a6b345337/src/components/Modal/Modal.js#L230-L238.

We have other places where we open a modal without an overflow menu and the selectorPrimaryFocus logic runs fine. Is there something in the overflow menu that is preventing the modal from processing selectorPrimaryFocus?

@asudoh
Copy link
Contributor

asudoh commented Sep 26, 2019

Seems that you hit #4088, too. Adding focusTrap={false} to <Modal> is a workaround there.

@kinueng
Copy link
Contributor Author

kinueng commented Sep 27, 2019

Hi @asudoh,
Got the Modal focus to work with the two workarounds (#4036 (comment), #4036 (comment))

See here for an example
https://codesandbox.io/s/codesandbox-m8c6c

@dakahn dakahn added this to the Modal - A11y Project Team milestone Sep 30, 2019
@dakahn dakahn added version: 9 Issues pertaining to legacy Carbon priority: low severity: 1 https://ibm.biz/carbon-severity labels Sep 30, 2019
@dakahn dakahn removed this from the Modal - A11y Project Team milestone Nov 21, 2019
asudoh added a commit to asudoh/carbon-components that referenced this issue Feb 4, 2020
This change eliminates the need for application to put focus sentinel
by having `<Modal>`, `<ComposedModal>` and `<FloatingMenu>`
automatically put the focus sentinels.

This change also add support for reverse-focus-wrap feature to
`<Modal>` and `<ComposedModal>`, without needing using 3rd-party
`focus-trap-react` library. This helps applications hitting adverse
side-effects that `focus-trap-react` library causes (e.g. carbon-design-system#3021, carbon-design-system#3665
and carbon-design-system#4600).

Fixes carbon-design-system#3817.
Fixes carbon-design-system#4036.
Fixes carbon-design-system#4600.
asudoh added a commit that referenced this issue Feb 14, 2020
This change eliminates the need for application to put focus sentinel
by having `<Modal>`, `<ComposedModal>` and `<FloatingMenu>`
automatically put the focus sentinels.

This change also add support for reverse-focus-wrap feature to
`<Modal>` and `<ComposedModal>`, without needing using 3rd-party
`focus-trap-react` library. This helps applications hitting adverse
side-effects that `focus-trap-react` library causes (e.g. #3021, #3665
and #4600).

Fixes #3817.
Fixes #4036.
Fixes #4600.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity: 1 https://ibm.biz/carbon-severity type: a11y ♿ version: 9 Issues pertaining to legacy Carbon
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants