Skip to content

SelectPanel: Add default empty message to announcement - #6346

Merged
francinelucca merged 12 commits into
mainfrom
tylerjdev/selectpanel-empty-announcement
Jul 23, 2025
Merged

SelectPanel: Add default empty message to announcement#6346
francinelucca merged 12 commits into
mainfrom
tylerjdev/selectpanel-empty-announcement

Conversation

@TylerJDev

@TylerJDevTylerJDev commented Jul 21, 2025

Copy link
Copy Markdown
Member

Addresses multiple audit issues:https://github.com/github/accessibility-audits/issues/12437, https://github.com/github/accessibility-audits/issues/11114

Ensures that the announcement for no items takes from DefaultEmptyMessage instead

Changelog

Changed

  • Adds default message for empty announcements in FilteredActionList and SelectPanel

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

Merge checklist

@changeset-bot

changeset-botBot commented Jul 21, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0c242ef

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

This PR includes changesets to release 1 package
NameType
@primer/reactPatch

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

@github-actionsgithub-actionsBot added staff Author is a staff member integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Jul 21, 2025
@github-actions

Copy link
Copy Markdown
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!

@francineluccafrancinelucca left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Tagged @llastflowers for review since this might intersect with the work she's doing as part of https://github.com/github/primer/issues/5377

@llastflowersllastflowers left a comment

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.

I left one comment, and the rest of the changes look fine to me! I'm wondering if the original message mismatch with the announcement had to do with the two different types of 'empty' messages being conflated? 🤔

Regarding my work on https://github.com/github/primer/issues/5377, I think I can build those changes on top of this without any issues!

Comment threadpackages/react/src/SelectPanel/SelectPanel.stories.tsx
@github-actions

github-actionsBot commented Jul 22, 2025

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize
packages/react/dist/browser.esm.js92.24 KB (-0.03% 🔽)
packages/react/dist/browser.umd.js92.36 KB (+0.01% 🔺)

@github-actions
github-actionsBot requested a deployment to storybook-preview-6346 July 22, 2025 19:28 Abandoned
Comment on lines +33 to +36
const EMPTY_MESSAGE = {
title: 'You haven’t created any items yet',
description: 'Please add or create new items to populate the list.',
}

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Added a const to hold our default messages. If we ever decide not to provide a default, we'll need to remove this.

(node: HTMLElement | null) => {
setListContainerElement(node)
if (!node && needsNoItemsAnnouncement) {
if (!node && needsNoItemsAnnouncement && !usingModernActionList) {

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I don't think we need to announce through SelectPanel if it's not using the modern action list. I was getting multiple of the same announcements, some through useAnnouncements and others through this file.

Comment on lines +45 to +48
messageText?: {
title: string
description: string
}

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

This is just so TypeScript doesn't yell. Won't be needed once we remove the FF.

@TylerJDev
TylerJDev marked this pull request as ready for review July 22, 2025 19:51
CopilotAI review requested due to automatic review settings July 22, 2025 19:51
@TylerJDev
TylerJDev requested a review from a team as a code ownerJuly 22, 2025 19:51
@TylerJDev
TylerJDev requested a review from joshblackJuly 22, 2025 19:51

CopilotAI left a comment

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.

Pull Request Overview

This PR ensures that SelectPanel components provide proper accessibility announcements for empty states by using default or provided empty messages instead of generic fallback text. The changes address accessibility audit issues by making screen reader announcements more informative.

Key changes:

  • Extracts default empty message into a reusable constant object
  • Updates announcement functions to use structured message content instead of hardcoded strings
  • Adds messageText prop to FilteredActionList components for configurable empty state announcements

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
SelectPanel.tsxRefactors empty message handling and updates announcement logic to use structured message content
SelectPanel.examples.stories.tsxAdds story demonstrating default message functionality
useAnnouncements.tsxUpdates hook to accept and use structured message parameter for empty state announcements
FilteredActionListWithModernActionList.tsxAdds messageText prop and passes it to useAnnouncements hook
FilteredActionListWithDeprecatedActionList.tsxAdds messageText prop interface (unused in deprecated implementation)
fresh-lines-guess.mdDocuments the patch-level change in changelog

description:
typeof message?.body === 'string'
? message.body
: EMPTY_MESSAGE.description || EMPTY_MESSAGE.description,

CopilotAIJul 22, 2025

Copy link

Choose a reason for hiding this comment

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

The fallback logic EMPTY_MESSAGE.description || EMPTY_MESSAGE.description is redundant. This should likely be message.body || EMPTY_MESSAGE.description to properly fallback to the default when message.body is falsy.

Suggested change
: EMPTY_MESSAGE.description||EMPTY_MESSAGE.description,
: message.body||EMPTY_MESSAGE.description,

Copilot uses AI. Check for mistakes.

if (items.length === 0 && !loading) {
announce('No matching items.', {delayMs})
announce(`${message?.title}. ${message?.description}`, {delayMs})

CopilotAIJul 22, 2025

Copy link

Choose a reason for hiding this comment

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

When message is undefined, this will announce 'undefined. undefined' to screen readers. Add a fallback: announce(message ? ${message.title}. ${message.description} : 'No matching items.', {delayMs})

Suggested change
announce(`${message?.title}. ${message?.description}`,{delayMs})
announce(message ? `${message.title}. ${message.description}` : 'No matching items.',{delayMs})

Copilot uses AI. Check for mistakes.
@github-actions
github-actionsBottemporarily deployed to storybook-preview-6346 July 23, 2025 15:46 Inactive
@francineluccafrancinelucca added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Jul 23, 2025
@primer
primerBot requested a review from a team as a code ownerJuly 23, 2025 15:57
@primer
primerBot requested a review from mperrottiJuly 23, 2025 15:57
@github-actionsgithub-actionsBot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Jul 23, 2025
@github-actions
github-actionsBottemporarily deployed to storybook-preview-6346 July 23, 2025 16:07 Inactive
@github-actions
github-actionsBot requested a deployment to storybook-preview-6346 July 23, 2025 18:07 Abandoned
@github-actions
github-actionsBottemporarily deployed to storybook-preview-6346 July 23, 2025 18:16 Inactive
@francinelucca
francinelucca added this pull request to the merge queueJul 23, 2025
Merged via the queue into main with commit 271630fJul 23, 2025
@francinelucca
francinelucca deleted the tylerjdev/selectpanel-empty-announcement branch July 23, 2025 18:35
@primerprimerBot mentioned this pull request Jul 23, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: recommendedThis change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpmstaffAuthor is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@TylerJDev@joshblack@francinelucca@llastflowers