fix: announce current page for pagination (#2419)
fix: announce current page for pagination
This commit is contained in:
parent
104c49449e
commit
eac4312030
3 changed files with 22 additions and 0 deletions
5
.changeset/purple-paws-scream.md
Normal file
5
.changeset/purple-paws-scream.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@lion/ui': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
[lion-pagination] announce current page
|
||||||
|
|
@ -287,6 +287,7 @@ export class LionPagination extends LocalizeMixin(LitElement) {
|
||||||
<button
|
<button
|
||||||
aria-label="${this.msgLit('lion-pagination:page', { page })}"
|
aria-label="${this.msgLit('lion-pagination:page', { page })}"
|
||||||
aria-current=${page === this.current}
|
aria-current=${page === this.current}
|
||||||
|
aria-live="${page === this.current ? 'polite' : 'off'}"
|
||||||
@click=${() => this.__fire(page)}
|
@click=${() => this.__fire(page)}
|
||||||
>
|
>
|
||||||
${page}
|
${page}
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,22 @@ describe('Pagination', () => {
|
||||||
expect(el.current).to.equal(2);
|
expect(el.current).to.equal(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should announce next and previous page using `next()` and `previous()`', async () => {
|
||||||
|
const el = await fixture(html` <lion-pagination count="6" current="2"></lion-pagination> `);
|
||||||
|
const buttons = Array.from(
|
||||||
|
/** @type {ShadowRoot} */ (el.shadowRoot).querySelectorAll('button'),
|
||||||
|
);
|
||||||
|
expect(buttons[2].getAttribute('aria-live')).to.equal('polite');
|
||||||
|
el.next();
|
||||||
|
await el.updateComplete;
|
||||||
|
expect(buttons[3].getAttribute('aria-live')).to.equal('polite');
|
||||||
|
expect(buttons[2].getAttribute('aria-live')).to.equal('off');
|
||||||
|
el.previous();
|
||||||
|
await el.updateComplete;
|
||||||
|
expect(buttons[3].getAttribute('aria-live')).to.equal('off');
|
||||||
|
expect(buttons[2].getAttribute('aria-live')).to.equal('polite');
|
||||||
|
});
|
||||||
|
|
||||||
it('should goto next and previous page using `next()` and `previous()`', async () => {
|
it('should goto next and previous page using `next()` and `previous()`', async () => {
|
||||||
const el = await fixture(html` <lion-pagination count="6" current="2"></lion-pagination> `);
|
const el = await fixture(html` <lion-pagination count="6" current="2"></lion-pagination> `);
|
||||||
el.next();
|
el.next();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue