Skip to content

Commit

Permalink
fix(pagination): prevent focus of disabled selectors
Browse files Browse the repository at this point in the history
Fixes #1108
Closes #1114

Closes #1114
  • Loading branch information
deeg authored and pkozlowski-opensource committed Dec 13, 2016
1 parent d1abd37 commit 733fc54
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/pagination/pagination.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@ function expectPages(nativeEl: HTMLElement, pagesDef: string[]): void {
expect(pages[i]).not.toHaveCssClass('active');
expect(pages[i]).toHaveCssClass('disabled');
expect(normalizeText(pages[i].textContent)).toEqual(pageDef.substr(1));
if (normalizeText(pages[i].textContent) !== '...') {
expect(pages[i].querySelector('a').getAttribute('tabindex')).toEqual('-1');
}
} else {
expect(pages[i]).not.toHaveCssClass('active');
expect(pages[i]).not.toHaveCssClass('disabled');
expect(normalizeText(pages[i].textContent)).toEqual(pageDef);
if (normalizeText(pages[i].textContent) !== '...') {
expect(pages[i].querySelector('a').hasAttribute('tabindex')).toBeFalsy();
}
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/pagination/pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import {NgbPaginationConfig} from './pagination-config';
<nav>
<ul [class]="'pagination' + (size ? ' pagination-' + size : '')">
<li *ngIf="boundaryLinks" class="page-item" [class.disabled]="!hasPrevious()">
<a aria-label="First" class="page-link" href (click)="!!selectPage(1)">
<a aria-label="First" class="page-link" href (click)="!!selectPage(1)" [attr.tabindex]="hasPrevious() ? null : '-1'">
<span aria-hidden="true">&laquo;&laquo;</span>
<span class="sr-only">First</span>
</a>
</li>
<li *ngIf="directionLinks" class="page-item" [class.disabled]="!hasPrevious()">
<a aria-label="Previous" class="page-link" href (click)="!!selectPage(page-1)">
<a aria-label="Previous" class="page-link" href (click)="!!selectPage(page-1)" [attr.tabindex]="hasPrevious() ? null : '-1'">
<span aria-hidden="true">&laquo;</span>
<span class="sr-only">Previous</span>
</a>
Expand All @@ -32,14 +32,14 @@ import {NgbPaginationConfig} from './pagination-config';
</li>
<li *ngIf="directionLinks" class="page-item" [class.disabled]="!hasNext()">
<a aria-label="Next" class="page-link" href (click)="!!selectPage(page+1)">
<a aria-label="Next" class="page-link" href (click)="!!selectPage(page+1)" [attr.tabindex]="hasNext() ? null : '-1'">
<span aria-hidden="true">&raquo;</span>
<span class="sr-only">Next</span>
</a>
</li>
<li *ngIf="boundaryLinks" class="page-item" [class.disabled]="!hasNext()">
<a aria-label="Last" class="page-link" href (click)="!!selectPage(pageCount)">
<a aria-label="Last" class="page-link" href (click)="!!selectPage(pageCount)" [attr.tabindex]="hasNext() ? null : '-1'">
<span aria-hidden="true">&raquo;&raquo;</span>
<span class="sr-only">Last</span>
</a>
Expand Down

0 comments on commit 733fc54

Please sign in to comment.