Skip to content

Conversation

@gjf20
Copy link
Contributor

@gjf20 gjf20 commented Dec 16, 2025

Summary:

Adds an aria-label to the externalIcon set to "Open in new tab". The aria label communicates the "new tab" information to screen reader users when they focus the link.

Issue: WB-2183

Test plan:

  • unit test
  • manual testing with the story:
Screen.Recording.2025-12-16.at.5.31.41.PM.mov

@gjf20 gjf20 self-assigned this Dec 16, 2025
@changeset-bot
Copy link

changeset-bot bot commented Dec 16, 2025

🦋 Changeset detected

Latest commit: 1f25e85

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

This PR includes changesets to release 5 packages
Name Type
@khanacademy/wonder-blocks-link Patch
@khanacademy/wonder-blocks-banner Patch
@khanacademy/wonder-blocks-pill Patch
@khanacademy/wonder-blocks-dropdown Patch
@khanacademy/wonder-blocks-birthday-picker 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

@khan-actions-bot khan-actions-bot requested a review from a team December 16, 2025 19:34
@khan-actions-bot
Copy link
Contributor

khan-actions-bot commented Dec 16, 2025

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to .changeset/unlucky-fishes-fail.md, __docs__/wonder-blocks-link/link.stories.tsx, packages/wonder-blocks-link/src/components/link-core.tsx, packages/wonder-blocks-link/src/components/link.tsx, packages/wonder-blocks-link/src/components/__tests__/link.test.tsx

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 16, 2025

npm Snapshot: Published

🎉 Good news!! We've packaged up the latest commit from this PR (6f12aca) and published all packages with changesets to npm.

You can install the packages in frontend by running:

./dev/tools/deploy_wonder_blocks.js --tag="PR2909"

Packages can also be installed manually by running:

pnpm add @khanacademy/wonder-blocks-<package-name>@PR2909

@github-actions
Copy link
Contributor

github-actions bot commented Dec 16, 2025

Size Change: +50 B (+0.05%)

Total Size: 110 kB

Filename Size Change
packages/wonder-blocks-link/dist/es/index.js 1.57 kB +50 B (+3.29%)
ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-accordion/dist/es/index.js 3 kB
packages/wonder-blocks-announcer/dist/es/index.js 1.74 kB
packages/wonder-blocks-badge/dist/es/index.js 2.02 kB
packages/wonder-blocks-banner/dist/es/index.js 2.01 kB
packages/wonder-blocks-birthday-picker/dist/es/index.js 1.92 kB
packages/wonder-blocks-breadcrumbs/dist/es/index.js 755 B
packages/wonder-blocks-button/dist/es/index.js 4.25 kB
packages/wonder-blocks-card/dist/es/index.js 1.08 kB
packages/wonder-blocks-cell/dist/es/index.js 2.18 kB
packages/wonder-blocks-clickable/dist/es/index.js 2.66 kB
packages/wonder-blocks-core/dist/es/index.js 2.48 kB
packages/wonder-blocks-data/dist/es/index.js 5.48 kB
packages/wonder-blocks-dropdown/dist/es/index.js 19.5 kB
packages/wonder-blocks-form/dist/es/index.js 6.2 kB
packages/wonder-blocks-grid/dist/es/index.js 1.24 kB
packages/wonder-blocks-icon-button/dist/es/index.js 4 kB
packages/wonder-blocks-icon/dist/es/index.js 1.91 kB
packages/wonder-blocks-labeled-field/dist/es/index.js 3.48 kB
packages/wonder-blocks-layout/dist/es/index.js 1.63 kB
packages/wonder-blocks-modal/dist/es/index.js 7.06 kB
packages/wonder-blocks-pill/dist/es/index.js 1.31 kB
packages/wonder-blocks-popover/dist/es/index.js 4.32 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.48 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.1 kB
packages/wonder-blocks-styles/dist/es/index.js 464 B
packages/wonder-blocks-switch/dist/es/index.js 1.55 kB
packages/wonder-blocks-tabs/dist/es/index.js 3.8 kB
packages/wonder-blocks-testing-core/dist/es/index.js 3.25 kB
packages/wonder-blocks-testing/dist/es/index.js 978 B
packages/wonder-blocks-theming/dist/es/index.js 384 B
packages/wonder-blocks-timing/dist/es/index.js 1.37 kB
packages/wonder-blocks-tokens/dist/es/index.js 5.01 kB
packages/wonder-blocks-toolbar/dist/es/index.js 906 B
packages/wonder-blocks-tooltip/dist/es/index.js 6.02 kB
packages/wonder-blocks-typography/dist/es/index.js 1.57 kB

compressed-size-action

@github-actions
Copy link
Contributor

github-actions bot commented Dec 16, 2025

A new build was pushed to Chromatic! 🚀

https://5e1bf4b385e3fb0020b7073c-hqklgcncpl.chromatic.com/

Chromatic results:

Metric Total
Captured snapshots 0
Tests with visual changes 0
Total stories 760
Inherited (not captured) snapshots [TurboSnap] 451
Tests on the build 451

size="small"
style={[styles.endIcon, styles.centered]}
testId="external-icon"
aria-label="Open in new tab"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do y'all agree with this wording for the aria label? I personally prefer this to "Open in a new tab" but I'm also open to other suggestions!

Copy link
Member

Choose a reason for hiding this comment

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

This will unfortunately replace the entire accessible name for links, which isn't what we want. I think you need to combine the textContent with the "open in new tab" text. It also needs to be translatable -- maybe through a prop?

Copy link
Member

Choose a reason for hiding this comment

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

Since the aria-label is being set on the external icon (rather than the link element), it doesn't seem to override the accessible name for the link! It seems to get included for the link name (let me know if I'm misunderstanding!):

Image

With it being alternative text for the icon, should the label be something like (Opens in a new tab) in brackets, to help separate it from the link name? Curious what your thoughts are on this @marcysutton !


+1 to making it a prop so translated strings can be passed in. Normally the WB components takes a labels prop for strings that can be passed in, and default values are provided for english. So something like this in the props:

type Props = {
  labels?: {
    externalIconAriaLabel?: string;
  }
}

Copy link
Member

Choose a reason for hiding this comment

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

Oh you're right @beaesguerra! My apologies -- I missed that it was on the icon, not on the Link itself! 🤦‍♀️

This should be fine as it is combining the text pieces together successfully: see screenshot below!

Historically the text for these kinds of interactions is "open in a new window", rather than a Tab. But maybe that's outdated!

Screenshot of Link docs in Accessibility developer tools

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks folks! I'll use "(opens in a new tab)" as the default

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've pushed up the changes and updated the demo recording in the PR description.
The changes include:

  • wrapping the message in parentheses to help separate the additional info from the link text
  • using "opens in a new tab" in English as a fallback
  • using a Wonderblocks-style labels prop

Thanks for your feedback!

size="small"
style={[styles.endIcon, styles.centered]}
testId="external-icon"
aria-label="Open in new tab"
Copy link
Member

Choose a reason for hiding this comment

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

This will unfortunately replace the entire accessible name for links, which isn't what we want. I think you need to combine the textContent with the "open in new tab" text. It also needs to be translatable -- maybe through a prop?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants