-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[Button] data-attribute not returned through onClick event #3311
Comments
Are you looking for ref by any chance? |
Not really, although that might work, and serve a similar purpose, I haven't tried it, but for vanilla elements it works and is more readable. Main problem here is that the Question is, would you want all Because I believe |
Sorry to re-open this thread, but I need exactly this functionality. I have a data attribute that I need to pass to my onChange function, and I have no way of doing this... Any ideas? Thanks! |
@Spyes I think this would need to be implemented per |
@TrySpace For now I've modified material UI's ListItem component to also include the data I pass to it into the div, thanks |
The next branch will have the same issue as it doesn't spam the ...other props into all elements that get created or cloned. My current work around is to lookup dataset in the parent hierarchy, as some element will have the correct data attribute populated, just maybe not the one you are expecting (or the one reported in event.target callbacks)
|
@baerrach Do you have a reproduction example with the v1-beta branch? Looking at the source code I would expect it to work but I could be wrong. |
I'm not use next yet, I know I scanned through the code but I can see through the blame view that the code has been there for ages. I can see: |
Thanks. Let's assume it's fixed until we have a reproduction example. |
@oliviertassinari what happened with this issue..? The comments have me somewhat confused, as it sounds like it was fixed, but I don't see any evidence of it. Currently we're using a button 'in the standard way', attempting to put data on it using This isn't the end of the world, as we can specify the
The problem arises when passing only text, like so:
With the above, if you click on the This is b/c the The solution in my eyes would be to just pass all data attributes to the Please let me know if I should create a new issue for this, if I've missed something, or if there's anything else I could do to help with this issue. |
@G-Rath The status of the issue is: no reproduction example = no bug. So yes, it's supposed to be good. I have a tip for you: |
@oliviertassinari sorry for taking so long to reply - only just had the time to check this out. Thanks a ton - works perfectly! I knew there was a property for exactly that purpose, as I've used it in the past, but couldn't find it anywhere. I suspect what threw me is that when inspecting the event in the console, Maybe it's worth dropping that line in the MUI docs somewhere, just as a couple of lines explaining how MUI handles |
|
I want to set a
data-tag
onMenuItem
and access it throughe.target.dataset.tag
but it doesn't get passed through.This works on vanilla elements.
Any idea how to get this working in another way? Or alternatively, would this be implemented in the future?
The text was updated successfully, but these errors were encountered: