Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix accessibility issues

Chocobozzz7667b26871b2
diff --git a/client/src/app/+my-library/my-history/my-history.component.html b/client/src/app/+my-library/my-history/my-history.component.html
index 4660dba63f..553a8d1062 100644
--- a/client/src/app/+my-library/my-history/my-history.component.html
+++ b/client/src/app/+my-library/my-history/my-history.component.html
@@ -1,3 +1,5 @@
+<h1 class="visually-hidden">{{ titlePage }}</h1>
+
<div class="top-buttons">
<div class="search-wrapper">
<my-search-input emitOnInit="true" (search)="onSearch($event)"></my-search-input>
diff --git a/client/src/app/+search/search.component.html b/client/src/app/+search/search.component.html
index bb8d88e621..8d62999c85 100644
--- a/client/src/app/+search/search.component.html
+++ b/client/src/app/+search/search.component.html
@@ -1,3 +1,5 @@
+<h1 class="visually-hidden" i18n>Search results</h1>
+
<div myInfiniteScroller (nearOfBottom)="onNearOfBottom()" [dataObservable]="onSearchDataSubject.asObservable()" class="search-result">
<div class="results-header">
<div class="first-line">
@@ -55,15 +57,18 @@
></my-actor-avatar>
<div class="video-channel-info">
- @if (!isExternalChannelUrl()) {
- <a [routerLink]="getInternalChannelUrl(result)" class="video-channel-names">
- <ng-container *ngTemplateOutlet="aContent"></ng-container>
- </a>
- } @else {
- <a [href]="getExternalChannelUrl(result)" target="_blank" class="video-channel-names">
- <ng-container *ngTemplateOutlet="aContent"></ng-container>
- </a>
- }
+ <!-- Keep the same heading level as the video and playlist results so every entry is reachable with heading navigation -->
+ <div role="heading" aria-level="2">
+ @if (!isExternalChannelUrl()) {
+ <a [routerLink]="getInternalChannelUrl(result)" class="video-channel-names">
+ <ng-container *ngTemplateOutlet="aContent"></ng-container>
+ </a>
+ } @else {
+ <a [href]="getExternalChannelUrl(result)" target="_blank" class="video-channel-names">
+ <ng-container *ngTemplateOutlet="aContent"></ng-container>
+ </a>
+ }
+ </div>
<ng-template #aContent>
<div class="video-channel-display-name me-2">{{ result.displayName }}</div>
@@ -91,7 +96,7 @@
<div class="entry video-playlist">
<my-video-playlist-miniature
[playlist]="result" displayAsRow="true" displayChannel="true" toManage="false"
- [linkType]="getLinkType()"
+ [linkType]="getLinkType()" [headingLevel]="2"
></my-video-playlist-miniature>
</div>
}
diff --git a/client/src/app/+video-list/overview/video-overview.component.html b/client/src/app/+video-list/overview/video-overview.component.html
index 18faca6567..4c83abc3ab 100644
--- a/client/src/app/+video-list/overview/video-overview.component.html
+++ b/client/src/app/+video-list/overview/video-overview.component.html
@@ -25,7 +25,7 @@
@for (object of objects; track object) {
<div class="section videos">
<div class="section-header d-flex flex-wrap justify-content-between align-items-start mb-3">
- <h1 class="section-title">
+ <h2 class="section-title">
@if (object.channel) {
<my-actor-avatar my-actor-avatar size="40" actorType="channel" [actor]="object.channel"></my-actor-avatar>
}
@@ -34,12 +34,12 @@
<span class="fg-100 fs-7 mx-2">·</span>
<span i18n class="fg-100 fs-7">{{ object.type }}</span>
- </h1>
+ </h2>
</div>
@for (video of object.videos; track video) {
<div class="video-wrapper">
- <my-video-miniature [video]="video" [user]="userMiniature" [displayVideoActions]="true" [headingLevel]="2"></my-video-miniature>
+ <my-video-miniature [video]="video" [user]="userMiniature" [displayVideoActions]="true" [headingLevel]="3"></my-video-miniature>
</div>
}
</div>
diff --git a/client/src/app/shared/shared-actor-image/actor-avatar.component.html b/client/src/app/shared/shared-actor-image/actor-avatar.component.html
index e10bb8b312..b3c8542beb 100644
--- a/client/src/app/shared/shared-actor-image/actor-avatar.component.html
+++ b/client/src/app/shared/shared-actor-image/actor-avatar.component.html
@@ -11,7 +11,10 @@
</ng-template>
@if (actor() && href()) {
- <a [href]="href()" target="_blank" rel="noopener noreferrer" [ariaHidden]="ariaHidden()" [title]="getTitle()">
+ <a
+ [href]="href()" target="_blank" rel="noopener noreferrer"
+ [ariaHidden]="ariaHidden()" [title]="getTitle()" [tabindex]="ariaHidden() ? -1 : 0"
+ >
<ng-template *ngTemplateOutlet="img"></ng-template>
</a>
} @else if (actor() && internalHref()) {
diff --git a/client/src/app/shared/shared-actor-image/actor-avatar.component.ts b/client/src/app/shared/shared-actor-image/actor-avatar.component.ts
index 480b57e3f7..f21e8a2a3f 100644
--- a/client/src/app/shared/shared-actor-image/actor-avatar.component.ts
+++ b/client/src/app/shared/shared-actor-image/actor-avatar.component.ts
@@ -52,6 +52,7 @@ export class ActorAvatarComponent implements OnInit, OnChanges {
readonly title = input<string>()
+ // Hide the avatar link from assistive technologies, for example when the parent component renders another link to the same actor
readonly ariaHidden = input(false, { transform: booleanAttribute })
getTitle () {
diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.html b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.html
index 300234e068..9c83bfe757 100644
--- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.html
+++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.html
@@ -1,3 +1,4 @@
+<!-- No "headingLevel" here: custom markup is embedded in user provided content, so we can't know the surrounding heading hierarchy -->
@if (video()) {
<my-video-miniature
[video]="video()" [user]="user" [displayAsRow]="false"
diff --git a/client/src/app/shared/shared-main/buttons/action-dropdown.component.html b/client/src/app/shared/shared-main/buttons/action-dropdown.component.html
index 32d803d84a..808a9f9dcf 100644
--- a/client/src/app/shared/shared-main/buttons/action-dropdown.component.html
+++ b/client/src/app/shared/shared-main/buttons/action-dropdown.component.html
@@ -10,8 +10,7 @@
class="action-button border-0"
[ngClass]="buttonClasses"
ngbDropdownToggle
- aria-label="Open actions"
- i18n-aria-label
+ [ariaLabel]="ariaLabel()"
>
@if (label()) {
<span class="me-2 dropdown-toggle-label">
diff --git a/client/src/app/shared/shared-main/buttons/action-dropdown.component.ts b/client/src/app/shared/shared-main/buttons/action-dropdown.component.ts
index fc175a064f..b703180eb3 100644
--- a/client/src/app/shared/shared-main/buttons/action-dropdown.component.ts
+++ b/client/src/app/shared/shared-main/buttons/action-dropdown.component.ts
@@ -67,6 +67,7 @@ export class ActionDropdownComponent<T, D = never> implements OnChanges {
readonly buttonStyled = input(true, { transform: booleanAttribute })
readonly label = input<string>(undefined)
+ readonly ariaLabel = input<string>($localize`Open actions`)
readonly theme = input<DropdownTheme>('secondary')
readonly openChange = output<boolean>()
diff --git a/client/src/app/shared/shared-thumbnail/video-thumbnail.component.html b/client/src/app/shared/shared-thumbnail/video-thumbnail.component.html
index a28a832901..8d1ff9aa00 100644
--- a/client/src/app/shared/shared-thumbnail/video-thumbnail.component.html
+++ b/client/src/app/shared/shared-thumbnail/video-thumbnail.component.html
@@ -1,7 +1,7 @@
@if (videoHref()) {
<a
[ariaHidden]="ariaHidden()"
- [ariaLabel]="ariaLabel()"
+ [ariaLabel]="ariaLabelText"
[href]="videoHref()"
[target]="videoTarget()"
class="video-thumbnail"
@@ -13,7 +13,7 @@
} @else {
<a
[ariaHidden]="ariaHidden()"
- [ariaLabel]="ariaLabel()"
+ [ariaLabel]="ariaLabelText"
[routerLink]="getVideoRouterLink()"
[queryParams]="queryParams()"
class="video-thumbnail"
@@ -24,30 +24,40 @@
</a>
}
+<!--
+ The overlays below live outside of the thumbnail link on purpose: that link can be aria-hidden (see the "ariaHidden" input),
+ and neither an interactive control nor screen reader only text may live inside an aria-hidden subtree
+-->
+
+@if (displayWatchLaterPlaylist()) {
+ <div class="actions-overlay">
+ <button
+ type="button"
+ class="watch-icon-overlay button-unstyle"
+ placement="left"
+ [ngbTooltip]="getWatchIconText()"
+ container="body"
+ #watchLaterTooltip="ngbTooltip"
+ (click)="onWatchLaterClick($event)"
+ [ariaLabel]="getWatchIconText()"
+ >
+ @if (inWatchLaterPlaylist()) {
+ <my-global-icon iconName="tick"></my-global-icon>
+ } @else {
+ <my-global-icon iconName="clock"></my-global-icon>
+ }
+ </button>
+ </div>
+}
+
+<!-- Duration, live state and watch progress are only rendered inside the (hidden) link, so expose them to screen readers here -->
+@if (ariaHidden()) {
+ <span class="visually-hidden">{{ a11yOverlaysSummary }}</span>
+}
+
<ng-template #aContent>
<img alt="" [attr.src]="src" [srcset]="srcset" [sizes]="sizes()" [ngClass]="{ 'blur-filter': blur() }" />
- @if (displayWatchLaterPlaylist()) {
- <div class="actions-overlay">
- <button
- class="watch-icon-overlay button-unstyle"
- placement="left"
- [ngbTooltip]="getWatchIconText()"
- container="body"
- #watchLaterTooltip="ngbTooltip"
- (click)="onWatchLaterClick($event)"
- [ariaLabel]="inWatchLaterPlaylist() ? removeFromWatchLaterText : addToWatchLaterText"
- [tabindex]="ariaHidden() ? -1 : 0"
- >
- @if (inWatchLaterPlaylist()) {
- <my-global-icon iconName="tick"></my-global-icon>
- } @else {
- <my-global-icon iconName="clock"></my-global-icon>
- }
- </button>
- </div>
- }
-
<div class="label-overlay pt-badge badge-warning"><ng-content select="label-warning"></ng-content></div>
<div class="label-overlay pt-badge badge-danger"><ng-content select="label-danger"></ng-content></div>
@@ -65,7 +75,7 @@
}
</div>
} @else if (getDurationLabel()) {
- <div class="duration-overlay" [ariaLabel]="getDurationOverlayLabel()">{{ getDurationLabel() }}</div>
+ <div class="duration-overlay">{{ getDurationLabel() }}</div>
}
@if (playOverlay()) {
@@ -77,7 +87,9 @@
@if (!video().isLive && video().userHistory?.currentTime) {
<div class="progress-bar">
<div [ngStyle]="{ 'width.%': getProgressPercent() }">
- <span class="visually-hidden" i18n>You watched {{ getProgressPercent() }}% of this video</span>
+ @if (!ariaHidden()) {
+ <span class="visually-hidden" i18n>You watched {{ getProgressPercent() }}% of this video</span>
+ }
</div>
</div>
}
diff --git a/client/src/app/shared/shared-thumbnail/video-thumbnail.component.scss b/client/src/app/shared/shared-thumbnail/video-thumbnail.component.scss
index 1e90a5045c..719cc79a01 100644
--- a/client/src/app/shared/shared-thumbnail/video-thumbnail.component.scss
+++ b/client/src/app/shared/shared-thumbnail/video-thumbnail.component.scss
@@ -2,6 +2,11 @@
@use "_mixins" as *;
@use "_miniature" as *;
+// Positioning context of ".actions-overlay", which is a sibling of ".video-thumbnail" and not one of its children
+:host {
+ position: relative;
+}
+
.video-thumbnail {
@include miniature-thumbnail;
}
@@ -77,9 +82,11 @@
flex-direction: column;
opacity: 0;
font-weight: $font-semibold;
+ z-index: z(miniature);
top: 5px;
- // right property is defined below
+
+ @include right(5px);
div:not(:first-child) {
margin-top: 2px;
@@ -103,10 +110,6 @@
.live-overlay {
left: 0;
}
-
- .actions-overlay {
- left: 5px;
- }
}
.video-thumbnail:not(.is-rtl) {
@@ -114,8 +117,4 @@
.live-overlay {
right: 0;
}
-
- .actions-overlay {
- right: 5px;
- }
}
diff --git a/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts b/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts
index 6bc74921d9..85daff3409 100644
--- a/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts
+++ b/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts
@@ -11,6 +11,7 @@ export type VideoThumbnailInput = Pick<
VideoServerModel,
| 'duration'
| 'id'
+ | 'name'
| 'uuid'
| 'shortUUID'
| 'isLive'
@@ -45,6 +46,7 @@ export class VideoThumbnailComponent implements OnChanges {
readonly inWatchLaterPlaylist = input<boolean, boolean | string>(false, { transform: booleanAttribute })
readonly playOverlay = input<boolean, boolean | string>(true, { transform: booleanAttribute })
+ // Hide the thumbnail link from assistive technologies, for example when the parent component already renders a link to the video
readonly ariaHidden = input(false, { transform: booleanAttribute })
readonly ariaLabel = input<string>()
readonly blur = input.required({ transform: booleanAttribute })
@@ -60,6 +62,9 @@ export class VideoThumbnailComponent implements OnChanges {
src: string
srcset: string
+ ariaLabelText: string
+ a11yOverlaysSummary: string
+
constructor () {
this.addToWatchLaterText = $localize`Add to watch later`
this.removeFromWatchLaterText = $localize`Remove from watch later`
@@ -78,12 +83,36 @@ export class VideoThumbnailComponent implements OnChanges {
this.srcset = thumbnails.filter(t => t.aspectRatio === '16:9')
.map(t => `${t.fileUrl} ${t.width}w`)
.join(', ')
+
+ this.ariaLabelText = this.buildAriaLabel()
+ this.a11yOverlaysSummary = this.buildA11yOverlaysSummary()
}
isRTL () {
return getLocaleDirection(this.localeId) === 'rtl'
}
+ // ---------------------------------------------------------------------------
+ // Accessibility
+ // ---------------------------------------------------------------------------
+
+ private buildAriaLabel () {
+ return this.ariaLabel() || $localize`Watch video ${this.video().name}`
+ }
+
+ // Text equivalent of the overlays rendered inside the thumbnail link, used when that link is hidden from assistive technologies
+ private buildA11yOverlaysSummary () {
+ const parts: string[] = []
+
+ if (this.video().isLive) parts.push(this.getLiveOverlayLabel())
+ else if (this.getDurationLabel()) parts.push(this.getDurationOverlayLabel())
+
+ const progressPercent = this.getProgressPercent()
+ if (progressPercent) parts.push($localize`You watched ${progressPercent}% of this video`)
+
+ return parts.join('. ')
+ }
+
getWatchIconText () {
if (this.inWatchLaterPlaylist()) return this.removeFromWatchLaterText
@@ -126,6 +155,14 @@ export class VideoThumbnailComponent implements OnChanges {
return $localize`Video duration is ${this.getDurationLabel()}`
}
+ getLiveOverlayLabel () {
+ if (this.isLiveStreaming()) return $localize`Live`
+ if (this.isEndedLive()) return $localize`Live ended`
+ if (this.isScheduledLive()) return $localize`Scheduled live ${this.scheduledLiveDate().toLocaleString()}`
+
+ return $localize`Waiting for live`
+ }
+
getVideoRouterLink () {
const videoRouterLink = this.videoRouterLink()
if (videoRouterLink) return videoRouterLink
diff --git a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.html b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.html
index fd92a7c522..ff7fce82d9 100644
--- a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.html
+++ b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.html
@@ -24,6 +24,7 @@
<my-action-dropdown
[actions]="videoActions"
[label]="label()"
+ [ariaLabel]="ariaLabel()"
[entry]="{ video: video() }"
[buttonSize]="buttonSize()"
[placement]="placement()"
diff --git a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts
index 4eda733475..80e8de889c 100644
--- a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts
+++ b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts
@@ -107,6 +107,7 @@ export class VideoActionsDropdownComponent implements OnChanges {
readonly actionAvailabilityHint = input(false, { transform: booleanAttribute })
readonly label = input<string>(undefined)
+ readonly ariaLabel = input<string>(undefined)
readonly buttonStyled = input(false, { transform: booleanAttribute })
readonly buttonSize = input<DropdownButtonSize>('normal')
@@ -338,7 +339,7 @@ export class VideoActionsDropdownComponent implements OnChanges {
},
error: err => {
- this.modalOpened.emit('remove')
+ this.modalClosed.emit('remove')
this.notifier.handleError(err)
}
diff --git a/client/src/app/shared/shared-video-miniature/video-miniature.component.html b/client/src/app/shared/shared-video-miniature/video-miniature.component.html
index d2b549961c..45631372a9 100644
--- a/client/src/app/shared/shared-video-miniature/video-miniature.component.html
+++ b/client/src/app/shared/shared-video-miniature/video-miniature.component.html
@@ -25,7 +25,7 @@
<ng-template #nsfwWarningButton>
@if (hasNSFWWarning()) {
- <button type="button" class="nsfw-warning button-unstyle ms-auto ps-1" [attr.aria-label]="nsfwTooltip" [ngbTooltip]="nsfwTooltip">
+ <button type="button" class="nsfw-warning button-unstyle ms-auto ps-1" [ariaLabel]="nsfwTooltip" [ngbTooltip]="nsfwTooltip">
<my-global-icon iconName="eye-close"></my-global-icon>
</button>
}
@@ -64,7 +64,7 @@
[href]="ownerHref"
[target]="ownerTarget"
inheritParentStyle="true"
- [title]="getOwnerAriaLabel()"
+ [title]="getOwnerLinkTitle()"
>
@if (displayOwnerAccount()) {
{{ authorAccount }}
@@ -107,6 +107,7 @@
<my-video-actions-dropdown
[video]="video()"
[displayOptions]="videoActionsDisplayOptions()"
+ [ariaLabel]="getVideoActionsLabel()"
placement="bottom-left bottom-right left auto"
(videoRemoved)="onVideoRemoved()"
(videoBlocked)="onVideoBlocked()"
diff --git a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts
index 071fe46bc0..8e2a719a19 100644
--- a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts
+++ b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts
@@ -237,18 +237,23 @@ export class VideoMiniatureComponent implements OnInit {
return this.video().privacy.id === VideoPrivacy.PASSWORD_PROTECTED
}
- getOwnerAriaLabel () {
- if (this.displayOwnerAccount()) {
- return $localize`Go to account ${this.authorAccount}`
- }
+ // The owner link always targets the channel page, even when we display the account name (see buildOwnerLink)
+ getOwnerLinkTitle () {
+ const owner = this.displayOwnerAccount()
+ ? this.authorAccount
+ : this.authorChannel
- return $localize`Go to channel ${this.authorChannel}`
+ return $localize`Go to the channel page of ${owner}`
}
getVideoAriaLabel () {
return $localize`Watch video ${this.video().name}`
}
+ getVideoActionsLabel () {
+ return $localize`Open actions of video ${this.video().name}`
+ }
+
loadActions () {
if (this.actionsLoaded) return
if (this.displayVideoActions()) this.showActions = true
diff --git a/client/src/app/shared/shared-video-miniature/videos-list.component.html b/client/src/app/shared/shared-video-miniature/videos-list.component.html
index b35e979a8f..0fc7f30028 100644
--- a/client/src/app/shared/shared-video-miniature/videos-list.component.html
+++ b/client/src/app/shared/shared-video-miniature/videos-list.component.html
@@ -74,7 +74,7 @@
[displayAsRow]="displayAsRow()"
[displayVideoActions]="displayVideoActions()"
[displayOptions]="displayOptions"
- [headingLevel]="3"
+ [headingLevel]="getVideosHeadingLevel()"
(videoBlocked)="removeVideoFromArray(video)"
(videoRemoved)="removeVideoFromArray(video)"
>
diff --git a/client/src/app/shared/shared-video-miniature/videos-list.component.ts b/client/src/app/shared/shared-video-miniature/videos-list.component.ts
index 8433e01adc..825a1745de 100644
--- a/client/src/app/shared/shared-video-miniature/videos-list.component.ts
+++ b/client/src/app/shared/shared-video-miniature/videos-list.component.ts
@@ -194,6 +194,13 @@ export class VideosListComponent implements OnInit, OnDestroy {
return video.id
}
+ // The "Videos" section title is only rendered when a "Lives" section precedes it, so don't introduce a heading level gap otherwise
+ getVideosHeadingLevel () {
+ return this.highlightedLives.length !== 0
+ ? 3
+ : 2
+ }
+
onNearOfBottom () {
if (this.disabled()) return
diff --git a/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.html b/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.html
index 51ebb7b100..322c93e7a4 100644
--- a/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.html
+++ b/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.html
@@ -19,6 +19,8 @@
<my-link
[internalLink]="playlistRouterLink" [href]="playlistHref" [target]="playlistTarget" inheritParentStyle="true" inheritParentDimension="true"
[title]="playlist().displayName" class="miniature-name" className="ellipsis-multiline-2"
+ [attr.role]="headingLevel() ? 'heading' : null"
+ [attr.aria-level]="headingLevel()"
>
{{ playlist().displayName }}
</my-link>
diff --git a/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts b/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts
index 7c344f2a52..80c5f465e2 100644
--- a/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts
+++ b/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts
@@ -29,6 +29,10 @@ export class VideoPlaylistMiniatureComponent implements OnInit {
readonly linkType = input<LinkType>('internal')
+ // Level of the playlist title in the page heading hierarchy (renders role="heading" + aria-level instead of a real h1-h6 tag,
+ // since the miniature can be reused at different nesting depths depending on the page)
+ readonly headingLevel = input<number>(undefined)
+
ownerRouterLink: any
ownerHref: string
ownerTarget: string