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

[useMenuButton] Create hooks for menu and menu button #1112

Open
diondiondion opened this issue Jul 7, 2020 · 5 comments
Open

[useMenuButton] Create hooks for menu and menu button #1112

diondiondion opened this issue Jul 7, 2020 · 5 comments

Comments

@diondiondion
Copy link

Hi there, thanks for your great work on Downshift!

We're currently using the useCombobox hook and will definitely be using useSelect for our custom select components.

I'm currently tasked with implementing an accessible menu button component for our product and was thinking about whether Downshift could be used for this purpose, too. There seems to be quite a bit of overlap between the ARIA design patterns of select/listbox and menu/menu button, so useSelect may be workable. Do you have any examples of this being done, or any advice on whether you think this is a good or bad idea? Do you maybe already have plans for a useMenuButton hook?

If I went with useSelect, I'd expect it to be necessary to override some of its defaults, for example the role of the menu will have to be menu, not listbox. But otherwise the functionality seems reasonably similar. Any pointers?

@diondiondion diondiondion changed the title Is useSelect suitable for implementing the ARIA menu button design pattern? Is useSelect suitable for implementing the ARIA menu button design pattern? Jul 7, 2020
@silviuaavram
Copy link
Collaborator

First of all I have to say that I would be super happy to have useMenuButton as a hook endorsed and provided by Downshift.

There is a similarity between the select and menu button but there are also a lot of different things, like having sub-menus and focus management in those menus.

I am not going to lie, it may take a while to develop it, but it would be super awesome! I will leave this issue open as a feature request, and we can start discussing specs and how we can use Downshift's principles in building it (stateReducer, control props, on change props etc).

@silviuaavram silviuaavram changed the title Is useSelect suitable for implementing the ARIA menu button design pattern? [useMenuButton] Create hooks for menu and menu button Sep 22, 2020
@YaseenAlGailani
Copy link
Contributor

YaseenAlGailani commented Sep 23, 2022

I’m really tempted to give this a try.

I’ve been through aria-practices's recommended specs for menus, and also been going through useSelect's implementation. There are considerable implementation differences, also keeping in mind changes landing with #1402.

@silviuaavram, If you're still interested in having useMenuButton provided by Downshift, I’d love to help. Thanks for your amazing work, I'm learning a lot from the code.

@briavicenti
Copy link

@YaseenAlGailani I'd be hugely interested in having a useMenuButton hook! We're currently trying to switch our component system to DownshiftJS from a different headless library, but we need a means of building a menu to be able to do so.

@YaseenAlGailani
Copy link
Contributor

@briavicenti I'm still interested as well. This discussion is barely going as you can see however, I might still submit a PR at some point (hopefully, if I don't get dragged into something else) cause I've already started implementing useMenuButton locally in a side project, and I have a bit of time at the moment.

@silviuaavram
Copy link
Collaborator

I think that useMultipleSelection or the other hooks can be of great help to create useMenuButton and useMenu. Not to use them per se, but to build the new hook according to the downshift patterns. Of course, ARIA guidelines for menu and menu button should be followed as well. There are also other similar hooks out there, I think react-aria (adobe spectrum) has one. Let me know if I can guide you further.

I am now focusing on some improvements for the existing hooks, so will not work on this directly, but will be happy to help as much as I can.

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

No branches or pull requests

4 participants