Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 97022d6

Browse files
Merge pull request #1259 from react-bootstrap-table/develop
20200216 release
2 parents 1aa4bbc + 2d418d8 commit 97022d6

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

‎packages/react-bootstrap-table2/src/contexts/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ const withContext = Base =>
8585
}
8686

8787
UNSAFE_componentWillReceiveProps(nextProps) {
88-
if (nextProps.columns.filter(col => col.sort).length > 0 && !this.SortContext) {
88+
if (nextProps.columns.filter(col => col.sort).length <= 0) {
89+
this.SortContext = null;
90+
} else if (!this.SortContext) {
8991
this.SortContext = createSortContext(
9092
dataOperator, this.isRemoteSort, this.handleRemoteSortChange);
91-
} else {
92-
this.SortContext = null;
9393
}
9494
if (!nextProps.pagination && this.props.pagination) {
9595
this.PaginationContext = null;

‎packages/react-bootstrap-table2/src/header-cell.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class HeaderCell extends eventDelegater(React.Component) {
7777

7878
if (sort) {
7979
const customClick = cellAttrs.onClick;
80+
cellAttrs['aria-label'] = sorting ? `${text} sort ${sortOrder}` : `${text} sortable`;
8081
cellAttrs.onKeyUp = (e) => {
8182
if (e.key === 'Enter') {
8283
onSort(column);

‎packages/react-bootstrap-table2/test/header-cell.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,11 @@ describe('HeaderCell', () => {
370370
});
371371
});
372372
});
373+
374+
it('should not have aria-label', () => {
375+
wrapper = shallow(<HeaderCell column={ column } index={ index } />);
376+
expect(wrapper.find('th').prop('aria-label')).toBeUndefined();
377+
});
373378
});
374379

375380
describe('when column.sort is enable', () => {
@@ -413,11 +418,20 @@ describe('HeaderCell', () => {
413418
expect(onSortCallBack.callCount).toBe(0);
414419
});
415420

421+
it('should have aria-label', () => {
422+
expect(wrapper.find('th').prop('aria-label')).toBe('ID sortable');
423+
});
424+
425+
416426
describe('and sorting prop is false', () => {
417427
it('header should render SortSymbol as default', () => {
418428
expect(wrapper.find(SortSymbol).length).toBe(1);
419429
});
420430

431+
it('should describe column header as sortable', () => {
432+
expect(wrapper.find('th').prop('aria-label')).toBe('ID sortable');
433+
});
434+
421435
describe('when sortCaret is defined ', () => {
422436
beforeEach(() => {
423437
column = { ...column, sortCaret: jest.fn() };
@@ -445,6 +459,10 @@ describe('HeaderCell', () => {
445459
<HeaderCell column={ column } index={ index } sortOrder={ order } sorting />);
446460
});
447461

462+
it('should describe sort order in aria-label', () => {
463+
expect(wrapper.find('th').prop('aria-label')).toBe(`ID sort ${order}`);
464+
});
465+
448466
it('should render SortCaret correctly', () => {
449467
expect(wrapper.find(SortCaret).length).toBe(1);
450468
expect(wrapper.find(SortCaret).prop('order')).toEqual(order);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /