From efe092861fb8f93b8ac432968f5453a1cf423576 Mon Sep 17 00:00:00 2001 From: Adam Dierkens Date: Mon, 6 Jul 2026 12:59:30 -0400 Subject: [PATCH 1/2] docs(Button): document built-in loading announcement Document that Button and IconButton automatically render a visually hidden polite live-region announcement (default "Loading") when the `loading` prop is set, that the text is customizable via `loadingAnnouncement`, and that consumers should not add their own aria-live loading message to avoid duplicate announcements. Closes #7881 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- packages/react/src/Button/Button.docs.json | 5 +++-- .../react/src/Button/Button.features.stories.tsx | 16 ++++++++++++++++ packages/react/src/Button/IconButton.docs.json | 11 +++++++++++ .../src/Button/IconButton.features.stories.tsx | 8 ++++++++ packages/react/src/Button/types.ts | 9 +++++++-- 5 files changed, 45 insertions(+), 4 deletions(-) diff --git a/packages/react/src/Button/Button.docs.json b/packages/react/src/Button/Button.docs.json index 91707c4c7bd..91bd01ae378 100644 --- a/packages/react/src/Button/Button.docs.json +++ b/packages/react/src/Button/Button.docs.json @@ -135,12 +135,13 @@ { "name": "loading", "type": "boolean", - "description": "When true, the button is in a loading state." + "description": "When true, the button is in a loading state. A spinner replaces the button's content and the button automatically announces its loading state to screen readers through a built-in, visually hidden live region. Do not add your own separate `aria-live` loading message for the button, as that would cause a duplicate announcement." }, { "name": "loadingAnnouncement", "type": "string", - "description": "The content to announce to screen readers when loading. This requires `loading` prop to be true" + "defaultValue": "'Loading'", + "description": "The text announced to screen readers through the built-in, visually hidden live region when the button enters its loading state. Requires the `loading` prop to be true." }, { "name": "ref", diff --git a/packages/react/src/Button/Button.features.stories.tsx b/packages/react/src/Button/Button.features.stories.tsx index 0b7d3da149b..cac3d8d733c 100644 --- a/packages/react/src/Button/Button.features.stories.tsx +++ b/packages/react/src/Button/Button.features.stories.tsx @@ -154,12 +154,28 @@ export const Medium = () => export const Large = () => export const Loading = () => +Loading.parameters = { + docs: { + description: { + story: + 'When `loading` is set, the button automatically renders a visually hidden live region that announces "Loading" to screen readers. Because this announcement is built in, do not add your own separate `aria-live` loading message for the button — doing so would cause a duplicate announcement.', + }, + }, +} export const LoadingCustomAnnouncement = () => ( ) +LoadingCustomAnnouncement.parameters = { + docs: { + description: { + story: + 'Use the `loadingAnnouncement` prop to customize the text announced to screen readers when the button enters its loading state. This replaces the default "Loading" announcement.', + }, + }, +} export const LoadingWithLeadingVisual = () => (