Skip to content
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 for arbitrary data attributes on upper element #3113

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

hogansghost
Copy link

  • Spread typesafe div props onto the upper element to allow for any data-attribute to be added to the top level.

Technically, this could also handle all of the aria tags as well by spreading the props but I was more concerned with adding arbitrary data-attributes over refactoring anything too heavily. This is to primarily allow for other tags such as data-cy for Cypress recommended naming selectors and to not require a specific prop for data-testid. The TS types for the Div element also prevent incorrect attributes being added:

Screenshot 2022-12-23 at 09 15 33

- Spread typesafe div props onto the upper element to allow
  for any data-attribute to be added to the top level.
@hogansghost
Copy link
Author

I just noticed my prettier did a number on this one, I can change that back if you prefer 👍

@hogansghost
Copy link
Author

Any opinion on this one at all? @nstepien @amanmahajan7

It would be super useful in my current project to target the multiple tables I have per page (rather than relying on testid for these elements only).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant