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

[Feature]: TagItem v8 support of data-* attributes #31366

Open
1 task done
kxmatejka opened this issue May 14, 2024 · 1 comment
Open
1 task done

[Feature]: TagItem v8 support of data-* attributes #31366

kxmatejka opened this issue May 14, 2024 · 1 comment
Labels
Fluent UI react (v8) Issues about @fluentui/react (v8) Type: Feature

Comments

@kxmatejka
Copy link

kxmatejka commented May 14, 2024

Library

React / v8 (@fluentui/react)

Describe the feature that you would like added

There isn't any prop that would allow identify TagItem component. It is problematic for e2e testing and tracking user interactions when you need to keep track of clicks on tag items, for example, within TagPicker component.

My proposition is to allow at least data-id attribute in ITagItemProps. Alternatively, any data-* as in HTML.

These data-* props would be propagated to IconButton.

Proposed interface would allow:

<TagItem data-id={`${props.item.id}-filter`}>{props.item.name}</TagItem>

In combination with TagPicker

<TagPicker
  onRenderItem={(props) => <TagItem {...props} data-id={`${props.item.id}-filter`}>{props.item.name}</TagItem>}
/>

Which would generate following HTML:

<div data-selection-index="1" ...>
  <span class="ms-TagItem-text text-283" ...>Identity</span>
  <button type="button" ... data-id="1001-filter">
    <span class="ms-Button-flexContainer flexContainer-142" ...>
      <i data-icon-name="Cancel" ...></i>
    </span>
  </button>
  <span id="id__1808-removeLabel" ...>Remove</span>
</div>

If this makes sense to you, I'm willing to send the PR.

Have you discussed this feature with our team

Yes, internally

Additional context

No response

Validations

  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Priority

Normal

@kxmatejka
Copy link
Author

I have a related issue with TagItemSuggestion. it supports data-* attributes, but it is a clickable div. Unfortunately, App Insights does not track clicks on div elements. If we change TagItemSuggestion from div to button, it should not break anything, it will be semantically correct and it will improve interoperability between FluentUi-App Insights.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fluent UI react (v8) Issues about @fluentui/react (v8) Type: Feature
Projects
None yet
Development

No branches or pull requests

2 participants