calcite-design-system icon indicating copy to clipboard operation
calcite-design-system copied to clipboard

Bug: calcite-popover - trap focus inside

Open AdelheidF opened this issue 3 years ago • 10 comments

All 3 sub-issues here a related, so I added them into the same issue.

(1) (fixed with the use of `calcite-list`)
Add an option to value list to not allow selection of the text, only `action-end`.

image

This is a lists of values in the filter component, clicking on a value name does not call an action. Only action-end matters here. image

This is a list of detailed information inside a popover. Nothing should happen when you click on the text, only action-end matters here as well. image

(2) (fixed with the use of `calcite-list`)
Navigating in this value list is a bit weird. Initially only the first row, first text then action-end, can be selected. If you then tab again it leaves the list. You need to use the down arrow to navigate inside the list, but the down arrow only works on the text, not on action-end. Same with `calcite-pick-list`.

(3) Focus gets lost if there if no other focusable item after the value-list when using tab key after action-end is selected. This is a problem for keyboard only users in the popover case above. How can I catch the focus (or know when the focus leaves value-list) and redirect it back to the close icon of the popover? I tried onBlur but that didn't work. Scenario: popover opens with close button on focus. Then I tab my way through the list. After the last focusable item in the list is active and I hit tab the focus gets lost.


New list component https://github.com/Esri/calcite-components/issues/2117

Actual Behavior

Expected Behavior

Reproduction Steps or Sample

Relevant Info

Version: @esri/calcite-components@<version>

  • [ ] CDN
  • [ ] NPM package

AdelheidF avatar May 13 '21 00:05 AdelheidF

Follow

TheBlueDog avatar May 27 '21 13:05 TheBlueDog

(1) and (2) are fixed with the use of the new calcite-list. (3) is still valid. Changed the title.

AdelheidF avatar Aug 05 '21 18:08 AdelheidF

@AdelheidF can you put together a codepen that illustrates this bug? Thanks!

macandcheese avatar Nov 05 '21 18:11 macandcheese

https://codepen.io/afreitag/pen/LYjmaWv?editors=1000

Click on the button to open the popover. Wait until focus sits on close button, now tab 4 times, all good. Now tab one more time, the focus should go back to the close button. How can I know that the focus left the list to set it back to the close button? A keyboard-only user would be lost now.

AdelheidF avatar Nov 09 '21 00:11 AdelheidF

Is this specific to list? Looking at it now it just seems like we don't trap focus inside a popover. That seems like a reasonable thing to have support though.

macandcheese avatar Jan 05 '22 17:01 macandcheese

Is this specific to list?

not really, trap focus inside a popover when only using tab key is the better description for what I need probably.

AdelheidF avatar Jan 05 '22 18:01 AdelheidF

another use case:

This popover has 2 focusable elements. image I tab once to get to the button image If I tab one more time the focus is lost from the popover and here on my browser page. image image

AdelheidF avatar Sep 12 '22 16:09 AdelheidF

Yeah, in that case the behavior could be more like a modal. If we add focus trapping to popover, do we need to offer disableEscape and related options from modal? cc @geospatialem

macandcheese avatar Sep 12 '22 17:09 macandcheese

Yeah, in that case the behavior could be more like a modal.

We got similar feedback from a screen reader user earlier this summer, as they were expecting functionality similar to a modal. Would be a great feature to add to the component.

do we need to offer disableEscape and related options from modal?

Ideally we'd like to always allow escape as an option for closing, as it is an expected behavior for keyboard users when open.

It looks like tooltip closes with the escape key, and there is no disableEscape property. Perhaps we could follow suit in this case as opposed to modal? We'd also need to add functionality to allow the escape key for closing the component, as its not currently built in.

geospatialem avatar Sep 12 '22 18:09 geospatialem

I think calcite-modal has the same issue.

We just got an issue from the accessibility testing group about this too.

Violation
Ensure that keyboard focus remains within modal dialogs

AdelheidF avatar Sep 14 '22 16:09 AdelheidF

@jcfranco should we use this npm package for this? https://www.npmjs.com/package/focus-trap

We could update the modal to use this package too.

driskull avatar Nov 01 '22 17:11 driskull

Installed and assigned for verification.

github-actions[bot] avatar Nov 18 '22 00:11 github-actions[bot]

Verified on next.639

verify-popover-trap

geospatialem avatar Nov 23 '22 15:11 geospatialem