-
Notifications
You must be signed in to change notification settings - Fork 842
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
Allow href and onClick in ListGroupItem #1933
Conversation
d53abb4
to
5cf9ddd
Compare
@joshdover As you might know this has been quite the controversial topic between EUI and Kibana. However, we've usually resolved that the use-case doesn't or shouldn't actually need this ability. Browser handling of href vs onClick can be unstable, though it is getting better. Our main concern usually comes back to accessibility. If it's conditional routing/handling of the click that you need, then you should be able to perform that condition before rendering the item and therefore supplying the correct onClick or href. However, we also don't know your particular use case, so feel free to explain. Here's a good button vs link checklist that I eventually intend to add to our guidelines:
|
Got it, thanks for the explanation. I think I've found a way to work around this. |
@cchaos I'm reopening this for discussion. One of the suggestions above is "Encourage routing in your application with href, react-router, etc". The way react-router actually handles this is by using both an This allows both "Open in new tab" behavior via right-click menu or CMD+click as well as allowing the SPA-style navigation I cannot find a way to replicate this behavior without having both |
@joshdover Ultimately I think we're throwing our hands up trying to enforce this. To get this PR good to go, can you document some best practices. Specifically just something in the prop docs to say we should attempt not to use onclick and href together. We just need something defensible when we do see this being used over aggressively. |
08fb02c
to
25cb856
Compare
@cchaos this is ready for review. I also converted this to TypeScript while I was here. This was to help with making sure the comments I added show up in IntelliSense in VSCode. I haven't done this conversion in EUI before, so let me know if there's any steps I missed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I'd like @thompsongl to double-check the TS conversions. The docs still behave the same way. Just found a couple typos
25cb856
to
c78a24c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TS conversion looks good to me
@joshdover I think this is good to go once the conflict is resolved |
c78a24c
to
fb93a3b
Compare
* Allow href and onClick in ListGroupItem * Convert EuiListGroup to TypeScript * PR comments
Summary
Having an
href
and anonClick
handler is a perfectly valid usecase that EUI should support. There are instances where you may want to override the default behavior withevent.preventDefault()
in an onClick handler in some conditions, but allow the default behavior in others.Checklist