Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[64235] [Accessibility] Provide alternative link texts for pagination links (#19333)

Behrokh Satarnejadc21d1f014276
diff --git a/config/locales/js-en.yml b/config/locales/js-en.yml
index d60b42ffb33..7f9bf78ebac 100644
--- a/config/locales/js-en.yml
+++ b/config/locales/js-en.yml
@@ -697,9 +697,12 @@ en:
pagination:
no_other_page: "You are on the only page."
+ pagination_controls: "Pagination controls"
pages:
- next: "Forward to the next page"
- previous: "Back to the previous page"
+ next: "Next page"
+ previous: "Previous page"
+ page_number: Page %{number}
+ show_per_page: Show %{number} per page
placeholders:
default: "-"
diff --git a/frontend/src/app/shared/components/table-pagination/table-pagination.component.html b/frontend/src/app/shared/components/table-pagination/table-pagination.component.html
index b5fc04549b3..406c866a654 100644
--- a/frontend/src/app/shared/components/table-pagination/table-pagination.component.html
+++ b/frontend/src/app/shared/components/table-pagination/table-pagination.component.html
@@ -1,6 +1,6 @@
<div class="op-pagination" *ngIf="pagination && isVisible && pagination.total">
- <nav class="op-pagination--pages">
- <ul class="op-pagination--items op-pagination--items_start">
+ <nav class="op-pagination--pages" [attr.aria-label]="text.pagination_controls">
+ <ul class="op-pagination--items op-pagination--items_start" role="presentation">
<li [hidden]="pagination.page === 1 || !showPageSelections" class="op-pagination--item">
<button
@@ -8,8 +8,7 @@
type="button"
(click)="showPage(pagination.page - 1)"
rel="prev start"
- [attr.aria-label]="text.label_previous"
- >
+ [attr.aria-label]="text.label_previous">
&#60;
</button>
</li>
@@ -32,17 +31,23 @@
<li *ngFor="let pageNumber of pageNumbers"
[ngClass]="{ 'op-pagination--item_current': pageNumber === pagination.page }"
class="op-pagination--item">
- <em *ngIf="pageNumber === pagination.page">{{ pageNumber }}</em>
+ <em
+ *ngIf="pageNumber === pagination.page"
+ [attr.aria-label]="text.page_number(pageNumber)"
+ aria-current="true"
+ tabindex="0">
+ {{ pageNumber }}
+ </em>
<button
class="op-pagination--item-link"
type="button"
*ngIf="pageNumber !== pagination.page"
(click)="showPage(pageNumber)"
rel="next"
+ [attr.aria-label]="text.page_number(pageNumber)"
[textContent]="pageNumber"
></button>
</li>
-
<li *ngIf="postPageNumbers.length" class="op-pagination--space">…</li>
</ng-container>
@@ -65,51 +70,59 @@
(click)="showPage(pagination.page + 1)"
rel="next"
class="op-pagination--item-link op-pagination--item-link_next"
- [attr.aria-label]="text.label_next"
- >
+ [attr.aria-label]="text.label_next">
&#62;
</button>
</li>
-
<li class="op-pagination--range">
<span [textContent]="currentRange"></span>
<span *ngIf="pageNumbers.length === 1"
- id="op-pagination-empty-text"
- tabindex="0"
- class="hidden-for-sighted"
- [textContent]="text.no_other_page"></span>
+ id="op-pagination-empty-text"
+ tabindex="0"
+ class="hidden-for-sighted"
+ [textContent]="text.no_other_page"></span>
</li>
-
<li class="op-pagination--info"
*ngIf="infoText">
<op-icon icon-classes="icon-info1 icon-context"></op-icon>
- <span [textContent]="infoText">
-
- </span>
+ <span [textContent]="infoText"></span>
</li>
</ul>
</nav>
- <div class="op-pagination--options"
- *ngIf="showPerPageOptions()">
- <ul class="op-pagination--items op-pagination--items_end">
- <li class="op-pagination--label" [textContent]="text.per_page" title="{{ text.per_page }}"></li>
-
- <li *ngFor="let perPageOption of perPageOptions"
+ <div class="op-pagination--options" *ngIf="showPerPageOptions()">
+ <nav [attr.aria-label]="text.pagination_controls">
+ <ul
+ class="op-pagination--items op-pagination--items_end"
+ role="presentation">
+ <li
+ class="op-pagination--label"
+ title="{{ text.per_page }}"
+ role="presentation"
+ [textContent]="text.per_page">
+ </li>
+ <li
+ *ngFor="let perPageOption of perPageOptions"
+ class="op-pagination--item"
[ngClass]="{ 'op-pagination--item_current': perPageOption === pagination.perPage }"
- class="op-pagination--item">
-
- <span *ngIf="perPageOption !== pagination.perPage">
- <button
- class="op-pagination--item-link"
- type="button"
- (click)="selectPerPage(perPageOption)"
- [textContent]="perPageOption"
- ></button>
- </span>
-
- <span *ngIf="perPageOption === pagination.perPage">{{ perPageOption }}</span>
- </li>
- </ul>
+ role="presentation">
+ <span *ngIf="perPageOption !== pagination.perPage">
+ <button
+ class="op-pagination--item-link"
+ type="button"
+ (click)="selectPerPage(perPageOption)"
+ [textContent]="perPageOption"
+ [attr.aria-label]="text.show_per_page(perPageOption)"
+ ></button>
+ </span>
+ <span *ngIf="perPageOption === pagination.perPage"
+ tabindex="0"
+ aria-current="true"
+ [attr.aria-label]="text.show_per_page(perPageOption)">
+ {{ perPageOption }}
+ </span>
+ </li>
+ </ul>
+ </nav>
</div>
</div>
diff --git a/frontend/src/app/shared/components/table-pagination/table-pagination.component.ts b/frontend/src/app/shared/components/table-pagination/table-pagination.component.ts
index 1737e93b470..027a7e98ffa 100644
--- a/frontend/src/app/shared/components/table-pagination/table-pagination.component.ts
+++ b/frontend/src/app/shared/components/table-pagination/table-pagination.component.ts
@@ -65,6 +65,9 @@ export class TablePaginationComponent extends UntilDestroyedMixin implements OnI
label_next: this.I18n.t('js.pagination.pages.next'),
per_page: this.I18n.t('js.label_per_page'),
no_other_page: this.I18n.t('js.pagination.no_other_page'),
+ pagination_controls: this.I18n.t('js.pagination.pagination_controls'),
+ page_number: (num:number) => this.I18n.t('js.pagination.pages.page_number', { number: num }),
+ show_per_page: (num:number) => this.I18n.t('js.pagination.pages.show_per_page', { number: num }),
};
public currentRange = '';