Skip to content

🐛 Prefer anchor and role="link" text over ancestor ARIA labels for RUM action names - #5013

Draft
anakorn-wm wants to merge 1 commit into
DataDog:mainfrom
anakorn-wm:anakorn/prefer-anchor-text-in-action-name
Draft

🐛 Prefer anchor and role="link" text over ancestor ARIA labels for RUM action names#5013
anakorn-wm wants to merge 1 commit into
DataDog:mainfrom
anakorn-wm:anakorn/prefer-anchor-text-in-action-name

Conversation

@anakorn-wm

Copy link
Copy Markdown

Motivation

Addresses bug report #5007

getActionNameFromElement runs every priorityStrategies entry against the target and up to 10 ancestors before ever falling back to text content of the target. When an anchor sits inside an ancestor with an aria-label or aria-labelledby (for example a role="dialog" whose aria-labelledby points at a visually-hidden title), RUM records the ancestor's label as the action name instead of the visible anchor text the user actually clicked.

This is common with accessible dialog primitives that require a title element on the dialog root, and it produces surprising click names like click on This is a modal window on every anchor inside the modal.

Changes

The ("BUTTON, LABEL or button-like element text") priority strategy now also matches <a> and role="link", mirroring the existing symmetry with <button> and role="button". The text content of the clicked anchor is picked at iteration 0 of the walk, so ancestor ARIA attributes no longer beat it.

Behavior change to flag: an <a> (or role="link") that carries both a visible text label and its own aria-label will now resolve to the visible text instead of the aria-label. That matches how <button> has always worked, but any team relying on the previous behavior will see a name shift. Not gated behind a config flag but happy to do so if desired.

Test instructions

yarn test:unit --spec packages/browser-rum-core/src/domain/action/getActionNameFromElement.spec.ts

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@anakorn-wm

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant