Skip to content

Commit 17017a8

Browse files
authored
Merge branch 'dev' into table-header-context-click
2 parents 4910f6b + 27ccc03 commit 17017a8

File tree

4 files changed

+238
-174
lines changed

4 files changed

+238
-174
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@
110110
"clean-css-cli": "^4.3.0",
111111
"codemirror": "^5.61.0",
112112
"codesandbox": "^2.2.3",
113-
"core-js": "^3.12.0",
113+
"core-js": "^3.12.1",
114114
"cross-env": "^7.0.3",
115-
"eslint": "^7.25.0",
115+
"eslint": "^7.26.0",
116116
"eslint-config-prettier": "^8.3.0",
117117
"eslint-config-standard": "^16.0.2",
118118
"eslint-config-vue": "^2.0.2",
@@ -130,11 +130,11 @@
130130
"husky": "^6.0.0",
131131
"improved-yarn-audit": "^2.3.2",
132132
"jest": "^26.6.3",
133-
"lint-staged": "^10.5.4",
133+
"lint-staged": "^11.0.0",
134134
"loader-utils": "^2.0.0",
135135
"lodash": "^4.17.21",
136136
"marked": "^2.0.3",
137-
"nuxt": "^2.15.4",
137+
"nuxt": "^2.15.5",
138138
"postcss": "^8.2.14",
139139
"postcss-cli": "^8.3.1",
140140
"prettier": "1.14.3",

src/components/table/helpers/mixin-sorting.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,15 +235,19 @@ export const sortingMixin = Vue.extend({
235235
}
236236
},
237237
sortTheadThAttrs(key, field, isFoot) {
238-
if (!this.isSortable || (isFoot && this.noFooterSorting)) {
238+
const { isSortable, noFooterSorting, localSortDesc, localSortBy, localSorting } = this
239+
if (!isSortable || (isFoot && noFooterSorting)) {
239240
// No attributes if not a sortable table
240241
return {}
241242
}
243+
242244
const sortable = field.sortable
245+
const sortKey = !localSorting ? field.sortKey ?? key : key
246+
243247
// Assemble the aria-sort attribute value
244248
const ariaSort =
245-
sortable && this.localSortBy === key
246-
? this.localSortDesc
249+
sortable && localSortBy === sortKey
250+
? localSortDesc
247251
? 'descending'
248252
: 'ascending'
249253
: sortable

src/components/table/table-sorting.spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,25 @@ describe('table > sorting', () => {
6363
expect(wrapper.emitted('sort-changed')[0][0].sortBy).toEqual('non-local')
6464
})
6565

66+
it('should set `aria-sort` when `field.sortKey` and `no-local-sorting` is used', async () => {
67+
const wrapper = mount(BTable, {
68+
propsData: {
69+
fields: [...testFields, { key: 'd', label: 'D', sortable: true, sortKey: 'non-local' }],
70+
items: testItems,
71+
noLocalSorting: true
72+
}
73+
})
74+
75+
expect(wrapper).toBeDefined()
76+
const $header = wrapper.findAll('thead > tr > th').at(3)
77+
78+
await $header.trigger('keydown.enter')
79+
expect(wrapper.emitted('sort-changed').length).toBe(1)
80+
expect(wrapper.emitted('sort-changed')[0][0].sortBy).toEqual('non-local')
81+
82+
expect($header.attributes('aria-sort')).toBe('ascending')
83+
})
84+
6685
it('should sort column descending when sortBy set and sortDesc changed, with proper attributes', async () => {
6786
const wrapper = mount(BTable, {
6887
propsData: {

0 commit comments

Comments
 (0)