Skip to content

fix(Token): Render <a/> tag as interactive element #6429

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

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

Conversation

devinmcinnis
Copy link

@devinmcinnis devinmcinnis commented Jul 31, 2025

Closes #

Changelog

New

Changed

  • Fixed isTokenInteractive function call in TokenBase.tsx to include the as prop: isTokenInteractive({as, ...rest})

Removed

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

The fix ensures that:

  • Button and anchor tokens correctly show data-cursor-is-interactive="true"
  • Non-interactive span tokens show data-cursor-is-interactive="false"
  • Tokens with onClick/onFocus handlers are properly detected as interactive
  • The CSS cursor styling (pointer vs auto) works as designed

All existing tests continue to pass, and new tests verify both the utility function behaviour and the integration with rendered components.

To compare, Storybook link before the change (cursor:auto on Link) vs after the change (cursor:pointer on Link).

Merge checklist

Copy link

changeset-bot bot commented Jul 31, 2025

🦋 Changeset detected

Latest commit: 7f78bef

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@devinmcinnis devinmcinnis changed the title Fix bug where <a/> tag should render as interactive element <a/> tag should render as interactive element Jul 31, 2025
@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Jul 31, 2025
Copy link
Contributor

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

Copy link
Contributor

github-actions bot commented Jul 31, 2025

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 90.12 KB (-0.09% 🔽)
packages/react/dist/browser.umd.js 90.44 KB (+0.07% 🔺)

@github-actions github-actions bot requested a deployment to storybook-preview-6429 July 31, 2025 20:19 Abandoned
@devinmcinnis devinmcinnis changed the title <a/> tag should render as interactive element Render <a/> tag as interactive element Jul 31, 2025
@github-actions github-actions bot temporarily deployed to storybook-preview-6429 July 31, 2025 20:29 Inactive
@devinmcinnis
Copy link
Author

(GitHub staff only) Integration tests pass at github/github (Learn more about how to run integration tests)

Tried following this but could not find the canary version

@devinmcinnis devinmcinnis marked this pull request as ready for review July 31, 2025 20:34
@Copilot Copilot AI review requested due to automatic review settings July 31, 2025 20:34
@devinmcinnis devinmcinnis requested a review from a team as a code owner July 31, 2025 20:34
@devinmcinnis devinmcinnis requested a review from joshblack July 31, 2025 20:34
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug in the TokenBase component where the as prop was not being passed to the isTokenInteractive function, causing anchor elements to be incorrectly treated as non-interactive. This affected the cursor styling, where anchor tokens showed cursor:auto instead of the expected cursor:pointer.

  • Fixed isTokenInteractive function call to include the as prop
  • Added comprehensive test coverage for interactive behavior across different element types
  • Added changeset for patch release

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/react/src/Token/TokenBase.tsx Fixed function call to pass as prop to isTokenInteractive
packages/react/src/Token/__tests__/Token.test.tsx Added tests for interactive behavior validation
.changeset/wet-crews-drum.md Added changeset documenting the fix

@joshblack joshblack enabled auto-merge August 8, 2025 17:35
@devinmcinnis devinmcinnis changed the title Render <a/> tag as interactive element fix(Token): Render <a/> tag as interactive element Aug 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants