couds / react-bulma-components

React components for Bulma framework
MIT License
1.2k stars 129 forks source link

[a11y] Navbar.Link > Navbar.Dropdown can't be focused using the keyboard #383

Open FunctionDJ opened 2 years ago

FunctionDJ commented 2 years ago

Describe the bug Title pretty much says it all. The Navbar.Dropdown component doesn't contain a <a> so it's not focuseable.

See official component viewer: https://couds.github.io/react-bulma-components/?path=/story/components-navbar--default

I've explored a few approaches between making the element focuseable using tabindex but then it still can't be triggered using the keyboard.

The correct solution would be to use the appropriate element for what the Navbar.Link should behave like: renderAs="button" This fixes basically all usability and accessibility issues, but unfortunately the browser default stylesheet bleeds through and makes the button look very ugly with a white background, border, changed font etc.

So instead of mopping that up with a lot more code i decided to use renderAs="a" with href="#" + event.preventDefault(). This is not ideal though. Optimally react-bulma-components would use a <button> in this case and apply the same styles and suppress the browser default styles.

It would be awesome if this component library can be made more accessible and keyboard friendly :)