Open alexcjohnson opened 4 years ago
My team could really use the ability to define data- properties on dcc components; the html components already have data- and aria- options available, this would be a good addition for dcc as well.
As for specific use cases for having this, we are trying to cover our application with Cypress UI tests, and the best practice for selecting elements in tests is by setting a 'data-cy' property on the components, to avoid coupling the test code to the structure and styling of the DOM.
Digging into this a little, nearly all of the dcc components have a wrapper <div>
or other actual DOM element that we could pass data-*
props along to. A prerequisite for this would be getting rid of Ramda.omit
when we use that to forward props to a 3rd-party library https://github.com/plotly/dash-core-components/issues/703
This isn't on our short-term roadmap, but if anyone would like to make a PR we'd be happy to review and help get it merged.
Split out from #475 - I'm happy to discuss this issue but don't want to distract from the very different meaning of wildcards in that issue. @ProbonoBonobo said:
If
dbc
hews close enough to raw HMTL elements that it's obvious how to naturally pass extra props on to them, then I'd encourage you to bring this up over there and add the appropriate extra props (Plotly does not maintaindbc
). But in general, dash components aren't simple enough for it to be clear where to pass arbitrary extra props on to - and if we did, they'd often be passed on to another library which in turn would just ignore them. So for the most part this would just be a way of stashing data on the prop, with no direct functional impact. The downside though is that errors can be significantly harder to track down - misspellings, misunderstandings, API changes, all become hunting expeditions rather than simple error messages.I think we'd be open to providing some sort of standard wildcard prefixes - I suppose this could even be
data-
andaria-
- if we can understand better the value it would bring. But other than the ability to disable prop checks, which you've already discovered, I don't think we want to allow just any arbitrary props. In fact internally we're kind of trying to go in the opposite direction, eg https://github.com/plotly/dash-core-components/issues/703