Skip to content

fix(a11y): add missing alt attributes to context icons and feedback images#115772

Merged
ryan953 merged 10 commits into
masterfrom
fix/add-alt-to-context-icon-and-feedback-images
May 26, 2026
Merged

fix(a11y): add missing alt attributes to context icons and feedback images#115772
ryan953 merged 10 commits into
masterfrom
fix/add-alt-to-context-icon-and-feedback-images

Conversation

@sentry-junior
Copy link
Copy Markdown
Contributor

@sentry-junior sentry-junior Bot commented May 19, 2026

Screen readers depend on alt text to describe images for people who can't see them. On the issue details page, our browser/OS/device context icons were <img> elements with no alt, so screen readers weren't relaying useful information.

This PR:

  • Wires alt={name} inside ContextIcon itself — PlatformIcon accepts HTMLImageElement attributes via rest props, so the name flows through to the <img> without adding a new public prop
  • Sets empty alt="" on decorative images in the feedback panel and empty state so screen readers skip them

No call-site changes needed for context icons.

Co-authored-by: Ryan Albrecht ralbrecht@sentry.io


View Session in Sentry

…mages

Add alt prop to ContextIconProps as an optional override that falls back
to the icon name. Pass a descriptive alt (e.g. 'browser: chrome') from
getContextIcon which has the semantic type context.

Mark decorative feedback onboarding/empty-state illustrations with
alt="" so screen readers skip them appropriately.
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 19, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 19, 2026

📊 Type Coverage Diff

✅ No new type safety issues introduced. Coverage: 93.58%

@macuzi macuzi marked this pull request as ready for review May 20, 2026 04:56
@macuzi macuzi requested review from a team as code owners May 20, 2026 04:56
@macuzi macuzi self-assigned this May 20, 2026
@ryan953 ryan953 requested review from a team and priscilawebdev May 20, 2026 16:11
@ryan953
Copy link
Copy Markdown
Member

ryan953 commented May 20, 2026

@priscilawebdev this is in the same-ish area as #115701 so i tagged you and design-eng to followup and help @macuzi get this over the line.

Looks like <PlatformIcon> doesn't accept an alt prop, and doesn't print and alt attribute to the dom. I think we should update platform icon to do something, maybe it can accept that prop, or maybe it should just know what alt to put based on the platform?

@macuzi
Copy link
Copy Markdown

macuzi commented May 20, 2026

Since aria-* attributes are best suited for non-interactive elements, we may need to rely on alt here.

So maybe need to update the platformicons package to explicitly include an alt?: string prop, or adjust the union so it only supports HTMLImageElement.

Comment thread static/app/components/events/contexts/contextIcon.tsx Outdated
Comment thread static/app/components/events/contexts/contextIcon.tsx Outdated
Co-authored-by: Ryan Albrecht <ryan@ryanalbrecht.ca>
@ryan953 ryan953 enabled auto-merge (squash) May 26, 2026 04:12
@ryan953 ryan953 added the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label May 26, 2026
@github-actions github-actions Bot removed the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label May 26, 2026
}
return <ContextIcon name={iconName} {...contextIconProps} />;
return (
<ContextIcon name={iconName} alt={`${type}: ${iconName}`} {...contextIconProps} />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: The ContextIcon component receives an alt prop, but it's not declared in its props or used, so the accessibility text is silently ignored.
Severity: LOW

Suggested Fix

Update the ContextIcon component to accept and use the alt prop. Add alt to the ContextIconProps interface, destructure it in the component's function signature, and pass it to the underlying rendered element that requires the accessibility text.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: static/app/components/events/contexts/utils.tsx#L367

Potential issue: The `ContextIcon` component is passed an `alt` prop from `utils.tsx` to
provide accessibility text. However, the component's props interface,
`ContextIconProps`, does not declare `alt`, and the function signature only destructures
the `name` and `size` props. Consequently, the `alt` prop is silently ignored by React
and not passed down to the underlying `PlatformIcon` component. This results in the
intended accessibility improvement being non-functional, as no alternative text is
rendered for the icon.

Did we get this right? 👍 / 👎 to inform future reviews.

No new public prop needed — PlatformIcon accepts HTMLImageElement
attributes via rest props, so passing alt={name} internally is enough.
Reverts the alt prop added at the call site in utils.tsx.

Co-authored-by: Ryan Albrecht <ralbrecht@sentry.io>

---
[View Session in Sentry](https://sentry.sentry.io/traces/?project=4510944073809921&query=gen_ai.conversation.id%3A%22slack%3AC08QLT0PYQK%3A1779768843.597129%22)
@ryan953 ryan953 added the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label May 26, 2026
@github-actions github-actions Bot removed the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label May 26, 2026
@ryan953 ryan953 added the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label May 26, 2026
Co-authored-by: Ryan Albrecht <ryan@ryanalbrecht.ca>
@github-actions github-actions Bot removed the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label May 26, 2026
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1960079. Configure here.

Comment thread static/app/components/events/contexts/contextIcon.tsx Outdated
Co-authored-by: Ryan Albrecht <ryan@ryanalbrecht.ca>
Co-authored-by: Ryan Albrecht <ryan@ryanalbrecht.ca>
Comment thread static/app/components/events/contexts/utils.tsx Outdated
@ryan953 ryan953 added the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label May 26, 2026
@ryan953 ryan953 merged commit cee9211 into master May 26, 2026
85 of 86 checks passed
@ryan953 ryan953 deleted the fix/add-alt-to-context-icon-and-feedback-images branch May 26, 2026 04:55
@ryan953
Copy link
Copy Markdown
Member

ryan953 commented May 26, 2026

Following up on PlatformIcons and ContextIcons here: getsentry/platformicons#239

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

Labels

Scope: Frontend Automatically applied to PRs that change frontend components Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants