Skip to content

feat(b-pagination, b-pagination-nav): improve aria accessibility (closes: #4811, #4160) #4810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Feb 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d655985
feat(b-pagination-nav): improve aria accessibility
tmorehouse Feb 21, 2020
e82c563
Update pagination-nav.spec.js
tmorehouse Feb 21, 2020
2303e3d
Update pagination.js
tmorehouse Feb 21, 2020
0bc5906
Update pagination.js
tmorehouse Feb 21, 2020
19f4f58
Update pagination.js
tmorehouse Feb 21, 2020
4e25ea8
Update pagination.js
tmorehouse Feb 21, 2020
0d8cbd2
lint
tmorehouse Feb 21, 2020
76ffa6a
Update README.md
tmorehouse Feb 21, 2020
36c776e
Update pagination.js
tmorehouse Feb 21, 2020
5f6275e
Update pagination-nav.spec.js
tmorehouse Feb 21, 2020
efbff8e
Update pagination.js
tmorehouse Feb 21, 2020
2a828b6
Update pagination.js
tmorehouse Feb 21, 2020
468e203
Update README.md
tmorehouse Feb 21, 2020
96c2e87
Update pagination.js
tmorehouse Feb 21, 2020
07475df
Merge branch 'dev' into pagination-aria
tmorehouse Feb 21, 2020
2b9eb91
render button instead of link for `b-pagination`
tmorehouse Feb 21, 2020
ed6f7f8
Update pagination.js
tmorehouse Feb 21, 2020
003eb01
Update pagination.js
tmorehouse Feb 21, 2020
30497ea
Update pagination.spec.js
tmorehouse Feb 21, 2020
b3f54dc
Update pagination.js
tmorehouse Feb 21, 2020
25cae91
Update pagination.js
tmorehouse Feb 21, 2020
4704ef8
Update pagination.js
tmorehouse Feb 21, 2020
ec70a30
Merge branch 'dev' into pagination-aria
jacobmllr95 Feb 22, 2020
bf0108b
Update pagination.js
jacobmllr95 Feb 22, 2020
c9739a2
Merge branch 'pagination-aria' of https://github.com/bootstrap-vue/bo…
jacobmllr95 Feb 22, 2020
dbef70e
Update pagination.js
jacobmllr95 Feb 22, 2020
0fa5c3d
Merge branch 'dev' into pagination-aria
tmorehouse Feb 23, 2020
1ae267f
Update README.md
tmorehouse Feb 23, 2020
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
2 changes: 1 addition & 1 deletion src/components/form-tags/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Form tags
# Form Tags

> Lightweight custom tagged input form control, with options for customized interface rendering,
> duplicate tag detection and optional tag validation.
Expand Down
13 changes: 2 additions & 11 deletions src/components/pagination-nav/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -515,23 +515,14 @@ recommended unless the content of the button textually conveys its purpose.

### Keyboard navigation

`<b-pagination-nav>` supports keyboard navigation out of the box, and follows the
[WAI-ARIA roving tabindex](https://www.w3.org/TR/wai-aria-practices-1.2/#kbd_roving_tabindex)
pattern.

- Tabbing into the pagination component will autofocus the current active page button
- <kbd>LEFT</kbd> (or <kbd>UP</kbd>) and <kbd>RIGHT</kbd> (or <kbd>DOWN</kbd>) arrow keys will focus
the previous and next buttons, respectively, in the page list
- <kbd>ENTER</kbd> or <kbd>SPACE</kbd> keys will select (click) the currently focused page button
- Pressing <kbd>TAB</kbd> will move to the next control or link on the page, while pressing
<kbd>SHIFT</kbd>+<kbd>TAB</kbd> will move to the previous control or link on the page.
`<b-pagination-nav>` supports standard <kbd>TAB</kbd> key navigation.

## See also

Refer to the [Router support](/docs/reference/router-links) reference page for router-link specific
props.

For pagination control of a component (such as `<b-table>`), use the
For pagination control of a component (such as `<b-table>`) or a pagination list, use the
[`<b-pagination>`](/docs/components/pagination) component instead.

<!-- Component reference added automatically from component package.json -->
7 changes: 4 additions & 3 deletions src/components/pagination-nav/pagination-nav.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('pagination-nav', () => {

// NAV Attributes
expect(wrapper.attributes('aria-hidden')).toBe('false')
expect(wrapper.attributes('aria-label')).toBe('Pagination')

// UL Classes
expect($ul.classes()).toContain('pagination')
Expand All @@ -41,9 +42,9 @@ describe('pagination-nav', () => {
expect($ul.classes()).not.toContain('justify-content-center')
expect($ul.classes()).not.toContain('justify-content-end')
// UL Attributes
expect($ul.attributes('role')).toBe('menubar')
expect($ul.attributes('role')).not.toBe('menubar')
expect($ul.attributes('aria-disabled')).toBe('false')
expect($ul.attributes('aria-label')).toBe('Pagination')
expect($ul.attributes('aria-label')).not.toBe('Pagination')

wrapper.destroy()
})
Expand Down Expand Up @@ -126,7 +127,7 @@ describe('pagination-nav', () => {
expect($ul.classes()).toContain('b-pagination')

// UL Attributes
expect($ul.attributes('role')).toBe('menubar')
expect($ul.attributes('role')).not.toBe('menubar')
expect($ul.attributes('aria-disabled')).toBe('true')

// LI classes
Expand Down
4 changes: 2 additions & 2 deletions src/components/pagination/pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ export const BPagination = /*#__PURE__*/ Vue.extend({
return pageNum
},
linkProps() {
// Always '#' for pagination component
return { href: '#' }
// No props, since we render a plain button
return {}
}
}
})
39 changes: 19 additions & 20 deletions src/components/pagination/pagination.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('pagination', () => {
if (index === 2) {
expect(li.classes()).toContain('active')
expect(li.classes()).not.toContain('disabled')
expect(pageLink.is('a')).toBe(true)
expect(pageLink.is('button')).toBe(true)
} else {
expect(li.classes()).not.toContain('active')
expect(li.classes()).toContain('disabled')
Expand All @@ -78,14 +78,13 @@ describe('pagination', () => {
expect(last.find('.page-link').text()).toEqual('»')

// Page button attrs
expect(page.find('.page-link').attributes('href')).toEqual('#')
expect(page.find('.page-link').attributes('type')).toEqual('button')
expect(page.find('.page-link').attributes('role')).toEqual('menuitemradio')
expect(page.find('.page-link').attributes('aria-checked')).toEqual('true')
expect(page.find('.page-link').attributes('aria-posinset')).toEqual('1')
expect(page.find('.page-link').attributes('aria-setsize')).toEqual('1')
expect(page.find('.page-link').attributes('tabindex')).toEqual('0')
expect(page.find('.page-link').attributes('aria-label')).toEqual('Go to page 1')
expect(page.find('.page-link').attributes('target')).toEqual('_self')

wrapper.destroy()
})
Expand Down Expand Up @@ -133,7 +132,7 @@ describe('pagination', () => {
disabled: false
})

const $links = wrapper.findAll('a.page-link')
const $links = wrapper.findAll('button.page-link')
expect($links.length).toBe(5)
expect($links.at(0).text()).toBe('Page 1')
expect($links.at(1).text()).toBe('Page 2')
Expand Down Expand Up @@ -388,16 +387,16 @@ describe('pagination', () => {
})
expect(wrapper.is('ul')).toBe(true)
expect(wrapper.findAll('li').length).toBe(5)
expect(wrapper.findAll('a.page-link').length).toBe(4)
expect(wrapper.findAll('a.page-link').is('[aria-controls="foo"]')).toBe(true)
expect(wrapper.findAll('button.page-link').length).toBe(4)
expect(wrapper.findAll('button.page-link').is('[aria-controls="foo"]')).toBe(true)

wrapper.setProps({
ariaControls: null
})
await waitNT(wrapper.vm)
expect(wrapper.findAll('li').length).toBe(5)
expect(wrapper.findAll('a.page-link').length).toBe(4)
expect(wrapper.findAll('a.page-link').is('[aria-controls]')).toBe(false)
expect(wrapper.findAll('button.page-link').length).toBe(4)
expect(wrapper.findAll('button.page-link').is('[aria-controls]')).toBe(false)

wrapper.destroy()
})
Expand All @@ -414,28 +413,28 @@ describe('pagination', () => {
})
expect(wrapper.is('ul')).toBe(true)
expect(wrapper.findAll('li').length).toBe(5)
expect(wrapper.findAll('a').length).toBe(4)
expect(wrapper.findAll('button').length).toBe(4)
expect(
wrapper
.findAll('a')
.findAll('button')
.at(0)
.attributes('aria-label')
).toBe('Go to page 1')
expect(
wrapper
.findAll('a')
.findAll('button')
.at(1)
.attributes('aria-label')
).toBe('Go to page 2')
expect(
wrapper
.findAll('a')
.findAll('button')
.at(2)
.attributes('aria-label')
).toBe('Go to page 3')
expect(
wrapper
.findAll('a')
.findAll('button')
.at(3)
.attributes('aria-label')
).toBe('Go to next page')
Expand Down Expand Up @@ -654,7 +653,7 @@ describe('pagination', () => {
wrapper
.findAll('li')
.at(3)
.find('a')
.find('button')
.trigger('click')
await waitNT(wrapper.vm)
expect(wrapper.vm.computedCurrentPage).toBe(2)
Expand All @@ -667,7 +666,7 @@ describe('pagination', () => {
wrapper
.findAll('li')
.at(6)
.find('a')
.find('button')
.trigger('keydown.space') // Generates a click event
await waitNT(wrapper.vm)
expect(wrapper.vm.computedCurrentPage).toBe(3)
Expand All @@ -678,7 +677,7 @@ describe('pagination', () => {
wrapper
.findAll('li')
.at(1)
.find('a')
.find('button')
.trigger('click')
await waitNT(wrapper.vm)
expect(wrapper.vm.computedCurrentPage).toBe(2)
Expand Down Expand Up @@ -1031,7 +1030,7 @@ describe('pagination', () => {
expect(wrapper.is('ul')).toBe(true)
await waitNT(wrapper.vm)
// Grab the button links (2 bookends + 3 pages + 2 bookends)
const links = wrapper.findAll('a.page-link')
const links = wrapper.findAll('button.page-link')
expect(links.length).toBe(7)

// Sanity check for getBCR override
Expand Down Expand Up @@ -1091,7 +1090,7 @@ describe('pagination', () => {
await waitNT(wrapper.vm)
expect(wrapper.is('ul')).toBe(true)
// Grab the button links (2 bookends + 3 pages + 2 bookends)
const links = wrapper.findAll('a.page-link')
const links = wrapper.findAll('button.page-link')
expect(links.length).toBe(7)

// Focus the last button
Expand Down Expand Up @@ -1121,14 +1120,14 @@ describe('pagination', () => {
await waitNT(wrapper.vm)
expect(wrapper.is('ul')).toBe(true)
// Grab the button links (2 disabled bookends + 4 pages + (-ellipsis) + 2 bookends)
links = wrapper.findAll('a.page-link')
links = wrapper.findAll('button.page-link')
expect(links.length).toBe(6)

// Click on the 4th button (page 4, index 3)
links.at(3).element.click()
await waitNT(wrapper.vm)
// Links re-rendered with first bookends enabled and an ellipsis
links = wrapper.findAll('a.page-link')
links = wrapper.findAll('button.page-link')
// The 4th link should be page 4, and retain focus
expect(document.activeElement).toEqual(links.at(3).element)

Expand Down
Loading