Blueprint: Spread data-* attributes onto elements

Created on 2 Oct 2019  路  7Comments  路  Source: palantir/blueprint

Feature request

Currently not all blueprint components propagate their data attributes to the rendered element and it would be great if they would, but for now we'd like to request data-* attributes on the Tab component.

We will can make more feature requests on other elements as we discover which ones are important. 馃槃

feature request

Most helpful comment

+1 in order to query Blueprint elements via getByTestId which uses the attribute data-testid.

All 7 comments

+1 in order to query Blueprint elements via getByTestId which uses the attribute data-testid.

+1 for this

It would be really nice to get this out. It's extremely helpful for integration tests to be able to store/access data-* attributes. Without it, I'm stuck with rather ugly hacks, like folding data into classes.

This was fixed for the Tab component in https://github.com/palantir/blueprint/pull/3766.

If there are other components where you need this feature, please list those out here.

I believe the Select<> component needs it as well.

I'd be open to a PR for this feature in <Select>, but it's not as simple as <Tab> because it's a more complicated component.

Can you show me an example of what you're doing in your test code? I'm potentially concerned that simply creating an easy selector for the wrapper element of a Select will not be sufficient for tests, and that you may end up reaching into the internals of the component, at which point you might as well use the exported class names:

import { Classes } from "@blueprintjs/select";

@adidahiya Please make it possible for <Alert> to have a data-testid as well, and it would be even better if we can assign data-testid for the cancel and confirm button in the <Alert> dialog.

@adidahiya I agree with @petejkim . Could it possible to send in a data-h (dataH) into <Alert> specifically for the Cancel and Confirm/[CUSTOM TEXT] buttons? Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sighrobot picture sighrobot  路  3Comments

westrem picture westrem  路  3Comments

sunabozu picture sunabozu  路  3Comments

tgreenwatts picture tgreenwatts  路  3Comments

raiju picture raiju  路  3Comments