dash icon indicating copy to clipboard operation
dash copied to clipboard

dash component generation doesn't work for hyphenated props

Open tsveti22 opened this issue 1 year ago • 1 comments

When generating new components using the dash typescript boilerplate, there is an issue with props containing a hyphen. E.g., if I try to generate bindings for a component, which has the "aria-expanded" prop, the generated Python class has "area-expanded" in its parameters, which throws an invalid syntax error, since python variables can't have hyphens.

def __init__(self, children=None, value=Component.REQUIRED, aria-expanded=Component.UNDEFINED, **kwargs):
        self._prop_names = ['children', 'id', 'about', 'accessKey', 'aria-expanded', ]

SyntaxError: invalid syntax

tsveti22 avatar May 03 '24 10:05 tsveti22

This topic has been around a long time. Just thought I'd consolidate a couple issues and forum posts that might be helpful - just in case it gets on the roadmap or sponsored.

  • https://community.plotly.com/t/can-data-attributes-be-created-in-dash/7222/2

  • This PR added a way to add data-* and aria-* props to dash html components https://github.com/plotly/dash/pull/237

  • https://github.com/plotly/dash/issues/1021

AnnMarieW avatar May 04 '24 15:05 AnnMarieW