-
Notifications
You must be signed in to change notification settings - Fork 26
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
Comments
Similar to #69. |
👍, a good use case for this is handling elements like react-router's Link that wrap anchor tags. |
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). |
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
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
Currently only
HTMLAnchorElement
s 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.
The text was updated successfully, but these errors were encountered: