Skip to content

fix: apply hover state on Tags with href#9750

Merged
yihuiliao merged 4 commits intoadobe:mainfrom
essandhu:fix/tag-hover-with-href
Mar 6, 2026
Merged

fix: apply hover state on Tags with href#9750
yihuiliao merged 4 commits intoadobe:mainfrom
essandhu:fix/tag-hover-with-href

Conversation

@essandhu
Copy link
Contributor

@essandhu essandhu commented Mar 6, 2026

Closes #9507

Adding the suggested fix from the above issue to the TagGroup aria component. Added a new test to cover the case where a Tag in a TagGroup has an href and is being hovered. No documentation or accessibility changes seem to be needed at the time

Before:

tag-hover-before.mp4

After:

tag-hover-after.mp4

✅ Pull Request Checklist:

  • [✅] Included link to corresponding React Spectrum GitHub Issue.
  • [✅] Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • [✅] Filled out test instructions.
  • [✅] Updated documentation (if it already exists for this component).
  • [✅] Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

Tested with the existing "Tag Group Example" under the aria components Storybook

  1. Open the Storybook page
  2. Scroll down to the "React Aria Components" folder. Navigate to the TabGroup component and click on the "Tab Group Example" example
  3. Inspect the properties of the first Tag with Chrome Dev Tools or a similar tool (should be a
    with class "react-aria-Tag"). Check for the data-hovered property
  4. Move the cursor over the first Tag in the example. Move the cursor off of the example.

Before code changes, the data-hovered attribute will never be displayed on the tag. After changes, data-hovered=true should display while the tag is hovered, and the attribute should disappear once no longer hovering.

Note: I added background color styles for local testing to ensure that was still working properly. This can be done by updating the following line:

style={({isSelected}) => ({border: '1px solid gray', borderRadius: 4, padding: '0 4px', background: isSelected ? 'black' : '', color: isSelected ? 'white' : '', cursor: props.href ? 'pointer' : 'default'})} />

to be this instead:

style={({isSelected, isHovered}) => ({border: '1px solid gray', borderRadius: 4, padding: '0 4px', background: isSelected ? 'black' : isHovered ? 'red' : '', color: isSelected ? 'white' : '', cursor: props.href ? 'pointer' : 'default'})} />

🧢 Your Project:

None

@github-actions github-actions bot added the RAC label Mar 6, 2026
@essandhu essandhu marked this pull request as ready for review March 6, 2026 05:25
@yihuiliao yihuiliao added this pull request to the merge queue Mar 6, 2026
Merged via the queue into adobe:main with commit 6829f06 Mar 6, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

data-hovered not triggered for Tag with href

3 participants