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

Add support for new element types to be used as menu items #174

Open
corymharper opened this issue Jul 17, 2020 · 3 comments · May be fixed by #325
Open

Add support for new element types to be used as menu items #174

corymharper opened this issue Jul 17, 2020 · 3 comments · May be fixed by #325

Comments

@corymharper
Copy link
Contributor

Currently only HTMLAnchorElements are supported for use as menu item elements with the hook. For flexibility, and as not to prescribe the implementation of the hook to developers using the package, making the ref's typing more generic but still type safe would be a warranted enhancement.

This will probably require an addition of passing generic types to the hook in order to accomplish.

@WesCossick
Copy link
Member

Similar to #69.

@msakrejda
Copy link
Contributor

👍, a good use case for this is handling elements like react-router's Link that wrap anchor tags.

@msakrejda
Copy link
Contributor

msakrejda commented Feb 21, 2022

Actually, because Link just renders an anchor, that's mostly moot here. But here's a different use case: menu items could be used to trigger form submission (e.g., see the log out action in this Remix example: https://remix.run/docs/en/v1/tutorials/jokes#build-logout-action -- you'll need to expand jokes.tsx).

jirutka added a commit to jirutka/react-accessible-dropdown-menu-hook that referenced this issue Oct 12, 2024
The code works with any HTML element, there's nothing that requires
specifically `HTMLAnchorElement` (`<a>`) except `e.currentTarget.href`
which is already conditional. Thus the current limitation is only a
typing issue introduced by unnecessarily specific `ref` type. We can
make it a generic parameter, but it wouldn't bring any real benefit,
just increase complexity and decrease flexibility.

Resolves sparksuite#174
@jirutka jirutka linked a pull request Oct 12, 2024 that will close this issue
jirutka added a commit to jirutka/react-accessible-dropdown-menu-hook that referenced this issue Oct 17, 2024
The code works with any HTML element, there's nothing that requires
specifically `HTMLAnchorElement` (`<a>`) except `e.currentTarget.href`
which is already conditional. Thus the current limitation is only a
typing issue introduced by unnecessarily specific `ref` type. We can
make it a generic parameter, but it wouldn't bring any real benefit,
just increase complexity and decrease flexibility.

Resolves sparksuite#174
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants