question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ContentSwitcher selection with arrow keys

See original GitHub issue

[ContentSwitcher selection with arrow keys]: ContentSwitcher works as expected when clicking the buttons - the index of the button selected (the desired button) is passed to the onChange event. When tabbing to the ContentSwitcher and using the left/right arrow keys to navigate it does not work as expected - the index of the current button (not the desired button) is passed to the onChange event (along with the key property i.e. key: “ArrowLeft”).

Environment

Operating system MacOS

Browser Chrome, FireFox

Automated testing tool and ruleset

Assistive technology used to verify

Detailed description

What version of the Carbon Design System are you using? 10

What did you expect to happen? When using the left/right arrow keys to navigate a ContentSwitcher I expected the correct button to be selected with focus on the desired button.

What happened instead? For example: I tabbed to the first ContentSwitcher item and pressed the right arrow key. The index passed to the onChange event was the index of the currently selected button so the content did not change as the button to the right was not selected. However, focus still moved to that button. The issue is the same when using the left arrow key. Every subsequent arrow press means focus is on the wrong button and does not align with the content displayed.

What WCAG 2.1 checkpoint does the issue violate?

Steps to reproduce the issue

  1. Tab to ContentSwitcher
  2. Press either the left or right arrow key

Additional information

This is what’s captured in the onChange function (see _ref) when clicking on the desired button (Sample Code button) image

This is what’s captured in the onChange function (see _ref) when trying to move off the Sample Code button to another on it’s left. (pressing the left arrow key on that button) image

I would expect the last scenario to say index: 0

Related issue: https://github.ibm.com/mhub/qp-planning/issues/5510

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
matthew-chirgwincommented, Jun 1, 2020

Hi @emyarod - I asked @Zoe-Gathercole1 to raise this issue given an a11y pass of the product we work on where we found this.

In an ideal world, the on click and on key press interaction would call our onChange with the same result content (ie I click on index 0, I am given 0, user presses arrow key left from index 1, the callback says index is 0 as a result etc). Honestly, if the ContentSwitcher worked like the Tab/Tabs (where we can nest our content in the child, and let the Tab/Tabs deal with which is selected) that would make our lives alot easier!

As is, we as a consumer of the ContentSwitcher need to know some of the internals of how it works to know how to respond (ie if ArrowLeft, -1 from index etc). If this were to change, we would break though. Would be interested to know what you would reccomend we do for now.

0reactions
joshblackcommented, Nov 12, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

jquery - How to use arrow keys to move selected elements
Arrow keys should move selected elements pixel by pixel in addition to moving by mouse. I tried code below but keydown event does...
Read more >
WASD and arrow keys swapped? Here's how to fix it
1. If you can, unplug your keyboard and plug it back in again, preferably into a different port. This is a quick fix...
Read more >
Selecting Tabs and Arrow Key Tab Switching - Mozilla Support
I don't think that there is a arrow key shortcut any more, but you can press CTRL + PageUp/PageDown to switch between next/previous...
Read more >
Use VoiceOver Quick Nav in apps and webpages on Mac
Navigate items in the current category: Press the Up Arrow or Down Arrow key. The VoiceOver cursor moves as you navigate items. The...
Read more >
Keyboard shortcuts - Microsoft Support
Perform the action for the selected Show All, Hide All, hidden text, or hyperlink. ENTER. Move back to the previous Help topic (Back...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found