reactstrap icon indicating copy to clipboard operation
reactstrap copied to clipboard

Any character opens Dropdown menu

Open eckdanny-osi opened this issue 8 years ago • 3 comments

  • components: Dropdown
  • reactstrap version 6.5.0
  • import method es
  • react version 16.5.2
  • bootstrap version 4.1.3

What is happening?

Any key (including e.g.; Esc or Shift) opens the Dropdown menu

What should be happening?

open the Dropdown (aria menu) only when Enter is pressed (from WAI ARIA 1.1)

Steps to reproduce issue

  1. keyboard nav to put focus on the DropdownToggle (the button tag)
  2. press a key

dropdown-bug

Code

Edit 1vo8knprml

eckdanny-osi avatar Nov 08 '18 03:11 eckdanny-osi

I've started working on a fork. 85% satisfied (leaving on road trip tmrw). Hoping to get a PR out early next week to address wai-aria/keyboard-nav improvements to Dropdown. The WiP Branch is here.

Gist of changes:

  • [x] Home/End key jumps
  • [x] up/down wraps
  • [x] spacebar enter interchangeable
  • [x] aria [role=menuitem]
  • [x] 1st item gets focus on menu expand
  • [x] misc focus mgmt
  • [ ] more tests
  • [ ] memoize some stuff

dropdown-upstream-pr

eckdanny-osi avatar Nov 09 '18 09:11 eckdanny-osi

It should default to how bootstrap does it. You can allow for extra props to control extra ability.

Bootstrap doesn't do any of these:

  • Home/End key jumps
  • up/down wraps
  • spacebar enter interchangeable
  • 1st item gets focus on menu expand

TheSharpieOne avatar Nov 12 '18 19:11 TheSharpieOne

d'oh! I'd been checking the PR Thread for feedback instead of here 🤕

Bootstrap doesn't do any of these:

  • Home/End key jumps
  • up/down wraps
  • spacebar enter interchangeable
  • 1st item gets focus on menu expand

Apologies. I've only recently become familiar with project history and at time of submission hadn't understood the implied goal: functional parity with Bootstrap.

  1. Home/End key jumps
    • 👎 not a feature in BS4
    • 🗯WAI-ARIA1.1 optional, but required "If arrow key wrapping is not supported"[1]
  2. up/down wraps
    • 👎 not a feature in BS4
    • 🗯WAI-ARIA1.1 optional
  3. spacebar/enter
    • 👍this does activate the menu button in BS4[2]
    • 🗯WAI-ARIA1.1 requires space and enter to "open the menu"[3]
  4. 1st item gets focus on menu expand*
    • 👎 not a feature in BS4
    • 🗯WAI-ARIA1.1 "place focus on the first menu item"[3][4]

IMO 2 is a bug b/c in BS4.1 only the following keyCodes: ESC, ENTER, SPACE, UP_ARROW, DOWN_ARROW open the menu in BS4. In 6.5.0, any keyDown event seems to toggle the menu.

WAI ARIA requires either 1 or 2, but BS4 fails this... what is the path to ARIA compliance here? (Same for 4). Raise in BS4.x, wait for fix, replicate here?

eckdanny-osi avatar Nov 20 '18 09:11 eckdanny-osi