Skip to content

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

Improve listing video miniature accessibility

Chocobozzzcd5aa184e3f7
diff --git a/client/src/app/+accounts/account-video-channels/account-video-channels.component.html b/client/src/app/+accounts/account-video-channels/account-video-channels.component.html
index 8fcc538996..6372cbd281 100644
--- a/client/src/app/+accounts/account-video-channels/account-video-channels.component.html
+++ b/client/src/app/+accounts/account-video-channels/account-video-channels.component.html
@@ -49,7 +49,7 @@
@for (video of getVideosOf(videoChannel); track video) {
<my-video-miniature
[video]="video" [user]="userMiniature" [displayVideoActions]="true" [displayOptions]="miniatureDisplayOptions"
- thumbnailSizes="201px"
+ thumbnailSizes="201px" [headingLevel]="3"
></my-video-miniature>
}
diff --git a/client/src/app/+search/search.component.html b/client/src/app/+search/search.component.html
index b6a8a77252..bb8d88e621 100644
--- a/client/src/app/+search/search.component.html
+++ b/client/src/app/+search/search.component.html
@@ -82,7 +82,7 @@
<div class="entry video">
<my-video-miniature
[video]="result" [user]="userMiniature" [displayAsRow]="true" [displayVideoActions]="!hideActions()"
- [displayOptions]="videoDisplayOptions" [videoLinkType]="getLinkType()"
+ [displayOptions]="videoDisplayOptions" [videoLinkType]="getLinkType()" [headingLevel]="2"
(videoBlocked)="removeVideoFromArray(result)" (videoRemoved)="removeVideoFromArray(result)"
></my-video-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 4fb7fe70a6..18faca6567 100644
--- a/client/src/app/+video-list/overview/video-overview.component.html
+++ b/client/src/app/+video-list/overview/video-overview.component.html
@@ -39,7 +39,7 @@
@for (video of object.videos; track video) {
<div class="video-wrapper">
- <my-video-miniature [video]="video" [user]="userMiniature" [displayVideoActions]="true"></my-video-miniature>
+ <my-video-miniature [video]="video" [user]="userMiniature" [displayVideoActions]="true" [headingLevel]="2"></my-video-miniature>
</div>
}
</div>
diff --git a/client/src/app/+video-watch/shared/recommendations/recommended-videos.component.html b/client/src/app/+video-watch/shared/recommendations/recommended-videos.component.html
index ac9c51f368..d4a8dcf1ce 100644
--- a/client/src/app/+video-watch/shared/recommendations/recommended-videos.component.html
+++ b/client/src/app/+video-watch/shared/recommendations/recommended-videos.component.html
@@ -25,7 +25,7 @@
<my-video-miniature
[displayOptions]="displayOptions" [video]="video" [user]="user" [displayAsRow]="displayAsRow()"
(videoBlocked)="onVideoRemoved()" (videoRemoved)="onVideoRemoved()" (muted)="onVideoRemoved()"
- actorImageSize="32" thumbnailSizes="201px"
+ actorImageSize="32" thumbnailSizes="201px" [headingLevel]="3"
>
</my-video-miniature>
@if (!playlist() && i === 0 && length > 1 && autoPlayNextVideo) {
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 77cee2b26a..e10bb8b312 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,11 +11,11 @@
</ng-template>
@if (actor() && href()) {
- <a [href]="href()" target="_blank" rel="noopener noreferrer" [title]="getTitle()">
+ <a [href]="href()" target="_blank" rel="noopener noreferrer" [ariaHidden]="ariaHidden()" [title]="getTitle()">
<ng-template *ngTemplateOutlet="img"></ng-template>
</a>
} @else if (actor() && internalHref()) {
- <a [routerLink]="internalHref()" [title]="getTitle()">
+ <a [routerLink]="internalHref()" [ariaHidden]="ariaHidden()" [title]="getTitle()" [tabindex]="ariaHidden() ? -1 : 0">
<ng-template *ngTemplateOutlet="img"></ng-template>
</a>
} @else {
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 a9da7295a7..480b57e3f7 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,8 @@ export class ActorAvatarComponent implements OnInit, OnChanges {
readonly title = input<string>()
+ readonly ariaHidden = input(false, { transform: booleanAttribute })
+
getTitle () {
if (this.title()) return this.title()
if (this.isAccount()) return $localize`${this.actor().name} (account page)`
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 cd0169cc87..a28a832901 100644
--- a/client/src/app/shared/shared-thumbnail/video-thumbnail.component.html
+++ b/client/src/app/shared/shared-thumbnail/video-thumbnail.component.html
@@ -1,9 +1,18 @@
@if (videoHref()) {
- <a [ariaLabel]="ariaLabel()" [href]="videoHref()" [target]="videoTarget()" class="video-thumbnail" [class]="{ 'is-rtl': isRTL() }" tabindex="-1">
+ <a
+ [ariaHidden]="ariaHidden()"
+ [ariaLabel]="ariaLabel()"
+ [href]="videoHref()"
+ [target]="videoTarget()"
+ class="video-thumbnail"
+ [class]="{ 'is-rtl': isRTL() }"
+ tabindex="-1"
+ >
<ng-container *ngTemplateOutlet="aContent"></ng-container>
</a>
} @else {
<a
+ [ariaHidden]="ariaHidden()"
[ariaLabel]="ariaLabel()"
[routerLink]="getVideoRouterLink()"
[queryParams]="queryParams()"
@@ -27,7 +36,8 @@
container="body"
#watchLaterTooltip="ngbTooltip"
(click)="onWatchLaterClick($event)"
- [attr.aria-label]="inWatchLaterPlaylist() ? removeFromWatchLaterText : addToWatchLaterText"
+ [ariaLabel]="inWatchLaterPlaylist() ? removeFromWatchLaterText : addToWatchLaterText"
+ [tabindex]="ariaHidden() ? -1 : 0"
>
@if (inWatchLaterPlaylist()) {
<my-global-icon iconName="tick"></my-global-icon>
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 2ddab64839..6bc74921d9 100644
--- a/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts
+++ b/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts
@@ -45,7 +45,8 @@ export class VideoThumbnailComponent implements OnChanges {
readonly inWatchLaterPlaylist = input<boolean, boolean | string>(false, { transform: booleanAttribute })
readonly playOverlay = input<boolean, boolean | string>(true, { transform: booleanAttribute })
- readonly ariaLabel = input.required<string>()
+ readonly ariaHidden = input(false, { transform: booleanAttribute })
+ readonly ariaLabel = input<string>()
readonly blur = input.required({ transform: booleanAttribute })
readonly watchLaterTooltip = viewChild<NgbTooltip>('watchLaterTooltip')
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 65045cdfee..8ab7813f76 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
@@ -1,9 +1,6 @@
@if (videoActions.length !== 0) {
@if (isUserLoggedIn() && displayOptions().playlist) {
<div
- role="button"
- aria-label="Open video actions"
- i18n-aria-label
class="playlist-dropdown"
ngbDropdown
#playlistDropdown="ngbDropdown"
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 79bd482f40..d2b549961c 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
@@ -1,6 +1,6 @@
<div class="video-miniature" [ngClass]="getClasses()" (mouseenter)="loadActions()" (focusin)="loadActions()">
<my-video-thumbnail
- [ariaLabel]="getAriaLabel()"
+ ariaHidden="true"
[blur]="hasNSFWBlur()"
[video]="video()"
[videoRouterLink]="videoRouterLink"
@@ -42,6 +42,7 @@
[size]="actorImageSize()"
[actor]="video().channel"
[internalHref]="[ '/c', video().byVideoChannel ]"
+ [ariaHidden]="displayOptions().by"
></my-actor-avatar>
} @else if (displayOwnerAccount()) {
<my-actor-avatar
@@ -50,6 +51,7 @@
[size]="actorImageSize()"
[actor]="video().account"
[internalHref]="[ '/c', video().byVideoChannel ]"
+ [ariaHidden]="displayOptions().by"
></my-actor-avatar>
}
}
@@ -62,8 +64,7 @@
[href]="ownerHref"
[target]="ownerTarget"
inheritParentStyle="true"
- [ariaLabel]="getAriaLabel()"
- [title]="displayOwnerAccount() ? authorAccount : authorChannel"
+ [title]="getOwnerAriaLabel()"
>
@if (displayOwnerAccount()) {
{{ authorAccount }}
@@ -71,9 +72,11 @@
{{ authorChannel }}
}
</my-link>
+
@if (!video().isLocal) {
<my-actor-host [host]="video().account.host"></my-actor-host>
}
+
@if (!displayAsRow()) {
<ng-container *ngTemplateOutlet="nsfwWarningButton"></ng-container>
}
@@ -88,25 +91,29 @@
[href]="videoHref"
[target]="videoTarget"
inheritParentStyle="true"
- [ariaLabel]="getAriaLabel()"
+ [ariaLabel]="getVideoAriaLabel()"
[title]="video().name"
class="video-name"
className="ellipsis-multiline-2"
+ [attr.role]="headingLevel() ? 'heading' : null"
+ [attr.aria-level]="headingLevel()"
>
{{ video().name }}
</my-link>
- <div class="video-actions">
- @if (showActions) {
- <my-video-actions-dropdown
- [video]="video()"
- [displayOptions]="videoActionsDisplayOptions()"
- placement="bottom-left bottom-right left auto"
- (videoRemoved)="onVideoRemoved()"
- (videoBlocked)="onVideoBlocked()"
- (videoUnblocked)="onVideoUnblocked()"
- (muted)="onMuted()"
- ></my-video-actions-dropdown>
+ <div class="video-actions" #videoActionsEl>
+ @defer (on viewport(videoActionsEl); prefetch on idle) {
+ @if (showActions) {
+ <my-video-actions-dropdown
+ [video]="video()"
+ [displayOptions]="videoActionsDisplayOptions()"
+ placement="bottom-left bottom-right left auto"
+ (videoRemoved)="onVideoRemoved()"
+ (videoBlocked)="onVideoBlocked()"
+ (videoUnblocked)="onVideoUnblocked()"
+ (muted)="onMuted()"
+ ></my-video-actions-dropdown>
+ }
}
</div>
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 b7cb8ceace..071fe46bc0 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
@@ -11,6 +11,7 @@ import {
numberAttribute,
output
} from '@angular/core'
+import { takeUntilDestroyed } from '@angular/core/rxjs-interop'
import { AuthService, ScreenService, ServerService, User } from '@app/core'
import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap'
import { HTMLServerConfig, VideoPlaylistType, VideoPrivacy } from '@peertube/peertube-models'
@@ -27,7 +28,6 @@ import { VideoThumbnailComponent } from '../shared-thumbnail/video-thumbnail.com
import { VideoPlaylistService } from '../shared-video-playlist/video-playlist.service'
import { VideoViewsCounterComponent } from '../shared-video/video-views-counter.component'
import { VideoActionsDisplayType, VideoActionsDropdownComponent } from './video-actions-dropdown.component'
-import { takeUntilDestroyed } from '@angular/core/rxjs-interop'
export type MiniatureDisplayOptions = {
date?: boolean
@@ -99,6 +99,10 @@ export class VideoMiniatureComponent implements OnInit {
readonly videoLinkType = input<LinkType>('internal')
+ // Level of the video 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)
+
readonly videoBlocked = output()
readonly videoUnblocked = output()
readonly videoRemoved = output()
@@ -233,7 +237,15 @@ export class VideoMiniatureComponent implements OnInit {
return this.video().privacy.id === VideoPrivacy.PASSWORD_PROTECTED
}
- getAriaLabel () {
+ getOwnerAriaLabel () {
+ if (this.displayOwnerAccount()) {
+ return $localize`Go to account ${this.authorAccount}`
+ }
+
+ return $localize`Go to channel ${this.authorChannel}`
+ }
+
+ getVideoAriaLabel () {
return $localize`Watch video ${this.video().name}`
}
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 685cfd2144..b35e979a8f 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
@@ -45,6 +45,7 @@
[displayAsRow]="displayAsRow()"
[displayVideoActions]="displayVideoActions()"
[displayOptions]="displayOptions"
+ [headingLevel]="3"
(videoBlocked)="removeVideoFromArray(live)"
(videoRemoved)="removeVideoFromArray(live)"
>
@@ -73,6 +74,7 @@
[displayAsRow]="displayAsRow()"
[displayVideoActions]="displayVideoActions()"
[displayOptions]="displayOptions"
+ [headingLevel]="3"
(videoBlocked)="removeVideoFromArray(video)"
(videoRemoved)="removeVideoFromArray(video)"
>
diff --git a/client/src/app/shared/shared-video-miniature/videos-selection.component.html b/client/src/app/shared/shared-video-miniature/videos-selection.component.html
index 0256caf157..60edef4af7 100644
--- a/client/src/app/shared/shared-video-miniature/videos-selection.component.html
+++ b/client/src/app/shared/shared-video-miniature/videos-selection.component.html
@@ -17,6 +17,7 @@
[displayOptions]="miniatureDisplayOptions()"
[displayVideoActions]="false"
[user]="user()"
+ [headingLevel]="headingLevel()"
></my-video-miniature>
@if (isInSelectionMode() === false) {
diff --git a/client/src/app/shared/shared-video-miniature/videos-selection.component.ts b/client/src/app/shared/shared-video-miniature/videos-selection.component.ts
index dbf8407732..5d777f32bd 100644
--- a/client/src/app/shared/shared-video-miniature/videos-selection.component.ts
+++ b/client/src/app/shared/shared-video-miniature/videos-selection.component.ts
@@ -38,6 +38,8 @@ export class VideosSelectionComponent implements AfterContentInit {
readonly getVideosObservableFunction = input<(page: number, sort?: VideoSortField) => Observable<ResultList<Video>>>(undefined)
+ readonly headingLevel = input(2)
+
readonly templates = contentChildren(PeerTubeTemplateDirective)
readonly selection = model<SelectionType>({})