@primer/view-components 0.24.2-rc.d5d453ee → 0.25.0-rc.f334329d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,12 +29,27 @@ document.addEventListener('clipboard-copy', ({ target }) => {
29
29
  if (!target.hasAttribute('data-view-component'))
30
30
  return;
31
31
  const currentTimeout = clipboardCopyElementTimers.get(target);
32
+ const clipboardCopyLiveRegion = target.parentNode?.querySelector('[data-clipboard-copy-feedback]');
33
+ const copiedAnnouncement = 'Copied!';
32
34
  if (currentTimeout) {
33
35
  clearTimeout(currentTimeout);
34
36
  clipboardCopyElementTimers.delete(target);
35
37
  }
36
38
  else {
37
39
  showCheck(target);
40
+ if (clipboardCopyLiveRegion) {
41
+ if (clipboardCopyLiveRegion.textContent === copiedAnnouncement) {
42
+ /* This is a hack due to the way the aria live API works.
43
+ A screen reader will not read a live region again
44
+ if the text is the same. Adding a space character tells
45
+ the browser that the live region has updated,
46
+ which will cause it to read again, but with no audible difference. */
47
+ clipboardCopyLiveRegion.textContent = `${copiedAnnouncement}\u00A0`;
48
+ }
49
+ else {
50
+ clipboardCopyLiveRegion.textContent = copiedAnnouncement;
51
+ }
52
+ }
38
53
  }
39
54
  clipboardCopyElementTimers.set(target, setTimeout(() => {
40
55
  showCopy(target);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/view-components",
3
- "version": "0.24.2-rc.d5d453ee",
3
+ "version": "0.25.0-rc.f334329d",
4
4
  "description": "ViewComponents for the Primer Design System",
5
5
  "main": "app/assets/javascripts/primer_view_components.js",
6
6
  "module": "app/components/primer/primer.js",