Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions packages/core/src/components/pagination/pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
Prop,
} from '@stencil/core';
import { BaseButton, BaseButtonProps } from '../button/base-button';
import { a11yBoolean } from '../utils/a11y';
import {
iconChevronLeftSmall,
iconChevronRightSmall,
Expand Down Expand Up @@ -166,7 +165,10 @@ export class Pagination {
onClick: () => this.selectPage(index),
selected: this.selectedPage === index,
ariaAttributes: {
'aria-pressed': a11yBoolean(this.selectedPage === index),
'aria-label': `Go to ${this.i18nPage} ${index + 1}`,
...(this.selectedPage === index
? { 'aria-current': 'page', 'aria-selected': 'true' }
: {}),
},
};

Expand Down Expand Up @@ -198,7 +200,14 @@ export class Pagination {
},
};
pageButtons.push(this.getPageButton(0));
pageButtons.push(<BaseButton {...baseButtonProps}>...</BaseButton>);
pageButtons.push(
<BaseButton
{...baseButtonProps}
ariaAttributes={{ 'aria-label': 'Jump backward 3 pages' }}
>
...
</BaseButton>
);

if (hasOverflowEnd) {
start = this.count - this.maxCountPages + 2;
Expand Down Expand Up @@ -232,7 +241,14 @@ export class Pagination {
}
},
};
pageButtons.push(<BaseButton {...baseButtonProps}>...</BaseButton>);
pageButtons.push(
<BaseButton
{...baseButtonProps}
ariaAttributes={{ 'aria-label': 'Jump forward 3 pages' }}
>
...
</BaseButton>
);
pageButtons.push(this.getPageButton(this.count - 1));
}

Expand All @@ -249,9 +265,10 @@ export class Pagination {

render() {
return (
<Host>
<Host role="navigation" aria-label="Pagination">
<ix-icon-button
disabled={!this.count || this.selectedPage === 0}
tabIndex={!this.count || this.selectedPage === 0 ? -1 : 0}
variant="subtle-tertiary"
icon={iconChevronLeftSmall}
onClick={() => this.decrease()}
Expand Down Expand Up @@ -298,6 +315,9 @@ export class Pagination {

<ix-icon-button
disabled={!this.count || this.selectedPage === this.count - 1}
tabIndex={
!this.count || this.selectedPage === this.count - 1 ? -1 : 0
}
variant="subtle-tertiary"
icon={iconChevronRightSmall}
onClick={() => this.increase()}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/pagination/test/pagination.ct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ regressionTest('should not change page', async ({ mount, page }) => {
const buttons = pagination.locator('button');
await buttons.nth(1).click();

await expect(buttons.first()).toHaveAttribute('aria-pressed', 'true');
await expect(buttons.nth(1)).toHaveAttribute('aria-pressed', 'false');
await expect(buttons.first()).toHaveAttribute('aria-selected', 'true');
await expect(buttons.nth(1)).not.toHaveAttribute('aria-selected', '');
});

regressionTest('should handle valid page input', async ({ mount, page }) => {
Expand Down
Loading