Allow href
to be set on an sl-menu-item
#1629
Replies: 16 comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
-
This is a dup of #292. I'm open to revisiting it, but accessibility and misuse (i.e. using @KonnorRogers see this comment and let me know your thoughts: #292 (comment) |
Beta Was this translation helpful? Give feedback.
-
This is as controversial as tabs vs. spaces. Buttons will continue to support You don't have to agree with it, but real world use cases occasionally demand it and I'm in favor of making things easier for users, not harder. Since the component handles everything under the hood for them, I don't see why this would be considered sloppy — but I'm also not interested in debating that tangent in this thread. |
Beta Was this translation helpful? Give feedback.
-
Ah, I missed the example you deep-linked to because the browser brought me to the top of the page. There's also this example, which clearly demonstrates menu items as anchors. https://www.w3.org/WAI/ARIA/apg/patterns/menubar/examples/menubar-navigation/ I'm OK with adding this as long as we continue to clarify that
|
Beta Was this translation helpful? Give feedback.
-
FYI — I hid some of the comments above to keep the discussion on track and positive. Please don't take it personally, folks. @CetinSert this does look like a valid use case with multiple sources that demonstrate it, so it's fair to entertain as a possibility. Again, we're here to enable users and this is something I've seen misused over and over again. Incorrectly wrapping or nesting anchors is quite common, even by experience devs, so I'm betting that supporting it will improve accessibility for many users. |
Beta Was this translation helpful? Give feedback.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
-
Then why is #1351 (comment) marked as off-topic? |
Beta Was this translation helpful? Give feedback.
-
This was explained in my previous comment. Here's a quick dump of problems many users will likely have with that:
I don't know why you're choosing to die on this hill but, once again, Shoelace is about enabling users to do things right with less thought and effort. If we add support for Can we please move on from this discussion now? |
Beta Was this translation helpful? Give feedback.
-
I really like shoelace and am migrating from another component library (material design) that has the href on menu-item feature. The href feature is really useful and the workaround in shoelace to achieve the same result feels really cumbersome (below in case anyone is searching for it), especially considering how easy it is to use shoelace components in general. Hope the href feature can be added in the future.
sl-menu-item::part(base) { sl-menu-item.link::part(submenu-icon), sl-menu-item.link a { sl-menu-item.link a:link, |
Beta Was this translation helpful? Give feedback.
-
What issue are you having?
Allow menu-items to act as anchors.
Describe the solution you'd like
If you pass an
href
to an<sl-menu-item>
it should render an anchor tag under the hood like<sl-button>
Describe alternatives you've considered
There's hacky ways like listening for
sl-select
event and manually firing a navigation event or constructing an anchor tag and clicking it.Why?
Well, it's actually a pattern on MDN.
https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/menuitem_role#examples
Additional notes
I know this opens the door to needing to support a whole slew of other attributes that anchors typically support.
Beta Was this translation helpful? Give feedback.
All reactions