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

Keyboard support not working for UncontrolledDropdown with menuRole="listbox" #2467

Closed
illandril opened this issue Mar 3, 2022 · 1 comment
Labels

Comments

@illandril
Copy link

  • components: UncontrolledDropdown
  • reactstrap version #9.0.1
  • import method es
  • react version #17.0.2
  • bootstrap version #5.1.3

What is happening?

Keyboard navigation doesn't work for UncontrolledDropdown when using menuRole="listbox".
It looks like the issue is this.context is an empty object when this.getMenuItems() is called, making it look for items with a role of menuitem instead of option, because getMenuItems doesn't realize the role is listbox.

What should be happening?

The user should be able to select options from the dropdown using the keyboard.

Steps to reproduce issue

  1. Tab to focus on the dropdown button
  2. Press enter (the menu should open up, with the correct option selected)
  3. Press down (the selection should move down one option)
  4. Press enter (the highlighted selection should be set as the value)

Error message in console

TypeError: Cannot read properties of undefined (reading 'focus')
    at eval (Dropdown.js:176:26)

Call stack

(anonymous) (Dropdown.js:176)
setTimeout (async)
handleKeyDown (Dropdown.js:176)
callCallback (react-dom.development.js:3945)
invokeGuardedCallbackDev (react-dom.development.js:3994)
invokeGuardedCallback (react-dom.development.js:4056)
invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4070)
executeDispatch (react-dom.development.js:8243)
processDispatchQueueItemsInOrder (react-dom.development.js:8275)
processDispatchQueue (react-dom.development.js:8288)
dispatchEventsForPlugins (react-dom.development.js:8299)
eval (react-dom.development.js:8508)
batchedEventUpdates$1 (react-dom.development.js:22396)
batchedEventUpdates (react-dom.development.js:3745)
dispatchEventForPluginEventSystem (react-dom.development.js:8507)
attemptToDispatchEvent (react-dom.development.js:6005)
dispatchEvent (react-dom.development.js:5924)
unstable_runWithPriority (scheduler.development.js:468)
runWithPriority$1 (react-dom.development.js:11276)
discreteUpdates$1 (react-dom.development.js:22413)
discreteUpdates (react-dom.development.js:3756)
dispatchDiscreteEvent (react-dom.development.js:5889)

Code

https://stackblitz.com/edit/reactstrap-z6t3bg?file=Example.js

@sowrovsarkar63
Copy link

Did you find any solution?

illiteratewriter added a commit to illiteratewriter/reactstrap that referenced this issue Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants