From 82923e2bdc38e4f04d54a786ade283f4effe20c1 Mon Sep 17 00:00:00 2001 From: Hector Alfaro Date: Thu, 5 Sep 2024 16:21:34 -0400 Subject: [PATCH] a11y: Standardize copy button announcement (#52229) --- package-lock.json | 1 + package.json | 1 + src/content-render/stylesheets/annotate.scss | 4 ++++ .../tests/__snapshots__/annotate.js.snap | 2 +- src/content-render/unified/code-header.js | 2 -- src/frame/components/lib/copy-code.ts | 9 ++++++--- src/rest/components/RestCodeSamples.tsx | 14 ++++++-------- 7 files changed, 19 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index 46d5c5941d67..8724adbea412 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "@octokit/request-error": "6.1.1", "@primer/behaviors": "^1.7.0", "@primer/css": "^21.3.1", + "@primer/live-region-element": "^0.7.0", "@primer/octicons": "^19.11.0", "@primer/octicons-react": "^19.11.0", "@primer/react": "36.27.0", diff --git a/package.json b/package.json index aa2742be7faf..5841f26e0356 100644 --- a/package.json +++ b/package.json @@ -232,6 +232,7 @@ "@octokit/request-error": "6.1.1", "@primer/behaviors": "^1.7.0", "@primer/css": "^21.3.1", + "@primer/live-region-element": "^0.7.0", "@primer/octicons": "^19.11.0", "@primer/octicons-react": "^19.11.0", "@primer/react": "36.27.0", diff --git a/src/content-render/stylesheets/annotate.scss b/src/content-render/stylesheets/annotate.scss index 624cd84ef4f6..b4199e62f09f 100644 --- a/src/content-render/stylesheets/annotate.scss +++ b/src/content-render/stylesheets/annotate.scss @@ -137,3 +137,7 @@ .subnav-item[aria-current]:not([aria-current="false"]) { z-index: 0; } + +button.js-btn-copy.copied::after { + content: "Copied!"; +} diff --git a/src/content-render/tests/__snapshots__/annotate.js.snap b/src/content-render/tests/__snapshots__/annotate.js.snap index d70eab5517f0..4b4594e468ce 100644 --- a/src/content-render/tests/__snapshots__/annotate.js.snap +++ b/src/content-render/tests/__snapshots__/annotate.js.snap @@ -1,7 +1,7 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`annotate > renders annotations 1`] = ` -"
YAML