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 data-attributes for all components #8561
Comments
Related #8305 |
All components accept |
@yesmeck using |
@yesmeck |
We could really use this feature as well. Abusing the |
Planning on something like this matthewlein@335807b |
@matthewlein why not allow passing any attributes? |
@apieceofbart Yea, my preference would be to pass everything, but I opted for the more conservative since I don't own this project. Ideally, I'd do something like
And now that I've looked at the codebase more, there are a fair amount of examples like that:
So maybe I will switch to that, it should cover Ultimately, I just want to do the one that will get merged though 😅. |
Yeah, I understand you totally, just a thought that |
True, types are where things could get a bit tricky. I realize now that the demos .md are not using typescript...I'll have to review that. You can allow any string prop with
|
hmmm but react allows any dom attribute, right? shouldn't this be in the types as well? |
@apieceofbart that article deals with jsx's handling of props, but that won't play into ant's component prop type-checking through typescript. Fortunately it seems to Just Work™. TS does not error on |
With #10922, the following list of components should be passing
|
I develop a babel-plugin to auto add test className. |
Currently I'm finding most Ant Design components work well with |
You could feel free to send PR to us for rest components which do not support yet. |
@DylanVann @afc163 I made that PR to rc-notification on Jun 20...4 months ago 😢 |
@matthewlein Could you resolve the conflict and I will handle it ASAP. |
@afc163 I rebased that PR: react-component/notification#54 |
It seems that |
It seems you can do this for tabs pane <Tabs.TabPane
tab={(
<span data-tid="...">
{ttitle}
</span>
)}
> And it will render the data-tid with the text of the tab |
That advice amounts to abusing an attribute that is highly volatile, subject to change and above all meant for styling as a means to query elements. There is a reason data-attributes exist and they also come in handy for ui-testing purposes: https://docs.cypress.io/guides/references/best-practices.html#Selecting-Elements. It would be really nice and would spare us a lot of workarounds if antd passed unmatched props (...otherProps) down to it's container elements or children. We worked around this by writing a HOC that wraps the Component in a div/span etc. which correctly handle data-attributes. |
antd 3.26.11 |
Up |
1 similar comment
Up |
Adding an extra span element will create a problem so slowness unnaseoerry element creation. |
What problem does this feature solve?
Hello, we are using antd in my team and we love it. In the process of our automated testing, we need to add custom html attributes to the DOM elements, so we can easily find them on the page. However most of the components do not respect custom attributes, thus not rendering them. Is it possible that such thing is implemented?
What does the proposed API look like?
Allow rendering ...rest properties, passed to a component.
The text was updated successfully, but these errors were encountered: