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

Other types of menu items? #173

Closed
tbohlen opened this issue Jul 17, 2020 · 5 comments
Closed

Other types of menu items? #173

tbohlen opened this issue Jul 17, 2020 · 5 comments
Labels

Comments

@tbohlen
Copy link

tbohlen commented Jul 17, 2020

This is a question rather than strictly an issue - apologies if this muddies your issue list!

Love what you've built. I'd like to be able to use this with button components within the menu, not just links in the case of an application menu. Given your knowledge about the accessibility requirements, are there any modifications to the props handed back by this hook that would need to be made to accomplish this from an accessibility standpoint?

Thanks!

@corymharper
Copy link
Contributor

Hi there, thanks for the interest in the package!

To my knowledge, there should be no accessibility issues with changing the a elements to button elements. The role of menuitem that is applied to the buttons should properly indicate that they are a button in a menu which will launch some action. As long as those buttons have semantically descriptive text as towards what their function is, I don't think there are accessibility concerns. If they do not, it's appropriate to add an aria-label property to the button.

However, there will be complaints from Typescript, as the package is currently only designed to accept HTMLAnchorElement as the target of it's ref. A possible and probably warranted feature addition is making the typing for menu items more generic.

@WesCossick
Copy link
Member

A possible and probably warranted feature addition is making the typing for menu items more generic.

@corymharper created #174 in response to this. Closing this issue in favor of that one.

@tbohlen
Copy link
Author

tbohlen commented Jul 18, 2020

Thanks Wes! Good to close.

@prios-chris-abbato
Copy link

One issue I have seen here is when trying to use a button in place of an anchor tag, any onClick listener is activated twice when using the Enter key. I believe this is because the default behavior of the button already activates the onClick and then this hook is also activating it. Changing the item element to a

corrects this.

@corymharper
Copy link
Contributor

One issue I have seen here is when trying to use a button in place of an anchor tag, any onClick listener is activated twice when using the Enter key. I believe this is because the default behavior of the button already activates the onClick and then this hook is also activating it. Changing the item element to a

corrects this.

That's a fair point, if we fully roll out support for other kinds of menu items we'll probably have to consider preventing the default behavior and the implications of that. For now, the package still only full supports HTMLAnchorElement children as menu items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants