Skip to content

Commit c107688

Browse files
authored
workaround for narrator announce the status changes of copy button (#8423)
Add aria-pressed attribute to indicate if copy button is pressed or not so that Narrator could read status change.
2 parents 2a4b380 + 4d616de commit c107688

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/NuGetGallery/Scripts/gallery/page-display-package.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,14 @@ $(function () {
9696
var text = $('#' + id + '-text').text().trim();
9797
window.nuget.copyTextToClipboard(text, copyButton);
9898
copyButton.popover('show');
99+
//This is workaround for Narrator announce the status changes of copy button to achieve accessibility.
100+
copyButton.attr('aria-pressed', 'true');
99101
setTimeout(function () {
100102
copyButton.popover('destroy');
101103
}, 1000);
104+
setTimeout(function () {
105+
copyButton.attr('aria-pressed', 'false');
106+
}, 1500);
102107
window.nuget.sendMetric("CopyInstallCommand", 1, {
103108
ButtonId: id,
104109
PackageId: packageId,

src/NuGetGallery/Views/Packages/DisplayPackage.cshtml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,14 @@
159159
<div class="install-script-row">
160160
<pre class="install-script" id="@packageManager.Id-text">@packageManager.InstallPackageCommand</pre>
161161
<div class="copy-button">
162+
<!--In order to statisfy the requirement to announce button status both on NVDA/Narrator, other screen reader like NVDA will
163+
announce the data-content "Copied" everytime when we press button, however, it won't work with Narrator when we use bootstrap popover
164+
because of known issue(https://github.com/twbs/bootstrap/issues/18618).
165+
We add aria-pressed to indicate the whether button is pressed or not, which is workaround only for Narrator announce the status change of button
166+
-->
162167
<button id="@packageManager.Id-button" class="btn btn-default btn-warning" type="button"
163168
data-toggle="popover" data-placement="bottom" data-content="Copied."
164-
aria-label="@packageManager.CopyLabel" aria-live="polite" role="status">
169+
aria-label="@packageManager.CopyLabel" aria-pressed="false" aria-live="polite" role="button">
165170
<span class="ms-Icon ms-Icon--Copy" aria-hidden="true"></span>
166171
</button>
167172
</div>

0 commit comments

Comments
 (0)