Skip to content

Commit 526705c

Browse files
authored
[A11y] Prevent hidden text when increasing text spacing (#8796)
Content in the Used By section gets incorrectly hidden when increasing the spacing in text. This fixes the accessibility bug by using `clamp.js` to clamp text. Note that this bug affects both the old and new designs, however, this fix only targets the redesign. See WCAG 2.1 requirement: https://www.w3.org/TR/WCAG21/#text-spacing Part of #8790
1 parent cd8eb6a commit 526705c

4 files changed

Lines changed: 24 additions & 28 deletions

File tree

src/Bootstrap/dist/css/bootstrap-theme.css

Lines changed: 0 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Bootstrap/less/theme/page-display-package-v2.less

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -274,25 +274,14 @@
274274
font-size: 14px;
275275
color: #333333;
276276
margin: 4px 0 0 0;
277-
width: auto;
278-
overflow: hidden;
279-
text-overflow: ellipsis;
280-
display: -webkit-box;
281277
line-height: 16px;
282-
/* fallback */
283-
max-height: 32px;
284-
/* fallback */
285-
-webkit-line-clamp: 2;
286-
/* number of lines to show */
287-
-webkit-box-orient: vertical;
288278
}
289279

290280
.used-by-link {
291281
font-family: @font-family-base;
292282
font-size: 16px;
293283
line-height: 19px;
294284
color: @brand-primary;
295-
width: auto;
296285
}
297286

298287
.gh-link, .ngp-link {

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,24 @@
110110
}
111111
}
112112

113+
var usedByClamped = false;
114+
var usedByTab = $('#usedby-tab');
115+
116+
function clampUsedByDescriptions() {
117+
// Clamp long descriptions in the "used by" tab. Ensure this runs only once,
118+
// otherwise clamp.js removes too much content.
119+
if (usedByClamped) return;
120+
if (!usedByTab.hasClass('active')) return;
121+
122+
for (var usedByDescription of $('.used-by-desc').get()) {
123+
$clamp(usedByDescription, { clamp: 2, useNativeClamp: false });
124+
}
125+
126+
usedByClamped = true;
127+
}
128+
129+
clampUsedByDescriptions();
130+
113131
// Make sure we save the user's preferred body tab to localStorage.
114132
$('.package-manager-tab').on('shown.bs.tab', function (e) {
115133
if (storage) {
@@ -128,6 +146,8 @@
128146
storage.setItem(bodyStorageKey, e.target.id);
129147
}
130148

149+
clampUsedByDescriptions();
150+
131151
window.nuget.sendMetric("ShowDisplayPackageTab", 1, {
132152
TabId: e.target.id,
133153
PackageId: packageId,

src/NuGetGallery/Views/Packages/DisplayPackageV2.cshtml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -707,13 +707,11 @@
707707
@if (item.IsVerified)
708708
{
709709
<img class="reserved-indicator"
710-
src="~/Content/gallery/img/reserved-indicator.svg"
711-
@ViewHelpers.ImageFallback(Url.Absolute("~/Content/gallery/img/reserved-indicator-14x14.png"))
712-
title="@Strings.ReservedNamespace_ReservedIndicatorTooltip" />
710+
src="~/Content/gallery/img/reserved-indicator.svg"
711+
@ViewHelpers.ImageFallback(Url.Absolute("~/Content/gallery/img/reserved-indicator-14x14.png"))
712+
title="@Strings.ReservedNamespace_ReservedIndicatorTooltip" />
713713
}
714-
<div class="row used-by-desc">
715-
<span>@(item.Description)</span>
716-
</div>
714+
<p class="used-by-desc">@item.Description</p>
717715
</td>
718716
<td>
719717
<i class="ms-Icon ms-Icon--Download used-by-download-icon" aria-hidden="true"></i> <label class="used-by-count">@(item.DownloadCount.ToKiloFormat())</label>

0 commit comments

Comments
 (0)