Skip to content

Commit 5dada3e

Browse files
Merge pull request #164 from plotly/118-ascending-sort
Sorting sorts ascending first and displays correct icon
1 parent e7d25dc commit 5dada3e

File tree

12 files changed

+36
-30
lines changed

12 files changed

+36
-30
lines changed

Diff for: packages/dash-table/CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -399,4 +399,8 @@ Derived properties allow the component to expose complex state that can be usefu
399399

400400
## RC8 - Improve props typing
401401

402-
Issue: https://github.com/plotly/dash-table/issues/143
402+
Issue: https://github.com/plotly/dash-table/issues/143
403+
404+
## RC9 - Sort ascending on first click
405+
- Sorts ascending when first clicked, [#118](https://github.com/plotly/dash-table/issues/118)
406+
- Flips icons displayed so that they are pointing up on ascending and down on descending.

Diff for: packages/dash-table/dash_table/bundle.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: packages/dash-table/dash_table/demo.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: packages/dash-table/dash_table/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dash-table",
3-
"version": "3.1.0rc8",
3+
"version": "3.1.0rc9",
44
"description": "Dash table",
55
"main": "build/index.js",
66
"scripts": {

Diff for: packages/dash-table/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dash-table",
3-
"version": "3.1.0rc8",
3+
"version": "3.1.0rc9",
44
"description": "Dash table",
55
"main": "build/index.js",
66
"scripts": {

Diff for: packages/dash-table/src/dash-table/Table.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ import Logger from 'core/Logger';
88

99
import genRandomId from './utils/generate';
1010

11+
function isFrontEnd(value) {
12+
return ['fe', true, false].indexOf(value) !== -1;
13+
}
14+
15+
function isBackEnd(value) {
16+
return ['be', false].indexOf(value) !== -1;
17+
}
18+
1119
export default class Table extends Component {
1220
constructor(props) {
1321
super(props);
@@ -23,14 +31,6 @@ export default class Table extends Component {
2331
pagination_mode
2432
} = this.props;
2533

26-
function isFrontEnd(value: any) {
27-
return ['fe', true, false].indexOf(value) !== -1;
28-
}
29-
30-
function isBackEnd(value: any) {
31-
return ['be', false].indexOf(value) !== -1;
32-
}
33-
3434
const isValid = isFrontEnd(pagination_mode) ||
3535
(isBackEnd(filtering) && isBackEnd(sorting));
3636

Diff for: packages/dash-table/src/dash-table/derived/header/content.tsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ function doSort(columnId: ColumnId, sortSettings: SortSettings, sortType: Sortin
2929
let direction: SortDirection;
3030
switch (getSorting(columnId, sortSettings)) {
3131
case SortDirection.Descending:
32-
direction = SortDirection.Ascending;
32+
direction = SortDirection.None;
3333
break;
3434
case SortDirection.Ascending:
35-
direction = SortDirection.None;
35+
direction = SortDirection.Descending;
3636
break;
3737
case SortDirection.None:
38+
direction = SortDirection.Ascending;
39+
break;
3840
default:
39-
direction = SortDirection.Descending;
41+
direction = SortDirection.Ascending;
4042
break;
4143
}
4244

@@ -68,9 +70,9 @@ function getSorting(columnId: ColumnId, settings: SortSettings): SortDirection {
6870
function getSortingIcon(columnId: ColumnId, sortSettings: SortSettings) {
6971
switch (getSorting(columnId, sortSettings)) {
7072
case SortDirection.Descending:
71-
return '↑';
72-
case SortDirection.Ascending:
7373
return '↓';
74+
case SortDirection.Ascending:
75+
return '↑';
7476
case SortDirection.None:
7577
default:
7678
return '↕';

Diff for: packages/dash-table/tests/cypress/tests/server/copy_paste_test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ describe('copy paste', () => {
101101
cy.get('tr th.column-2 .sort').last().click();
102102

103103
DashTable.getCell(0, 0).click();
104-
DashTable.getCell(0, 0).within(() => cy.get('.dash-cell-value').should('have.value', '103'));
104+
DashTable.getCell(0, 0).within(() => cy.get('.dash-cell-value').should('have.value', '11'));
105105

106106
DOM.focused.type(`${Key.Meta}c`);
107107

@@ -113,7 +113,7 @@ describe('copy paste', () => {
113113
.within(() => cy.get('.dash-cell-value').should('have.html', 'MODIFIED'));
114114
DashTable
115115
.getCell(1, 0)
116-
.within(() => cy.get('.dash-cell-value').should('have.value', '103'));
116+
.within(() => cy.get('.dash-cell-value').should('have.value', '11'));
117117

118118
DashTable.getCell(1, 1).click();
119119
DOM.focused.type(`${Key.Meta}c`);
@@ -126,7 +126,7 @@ describe('copy paste', () => {
126126
.within(() => cy.get('.dash-cell-value').should('have.value', 'MODIFIED'));
127127
DashTable
128128
.getCell(1, 0)
129-
.within(() => cy.get('.dash-cell-value').should('have.html', '103'));
129+
.within(() => cy.get('.dash-cell-value').should('have.html', '11'));
130130
});
131131
});
132132
});

Diff for: packages/dash-table/tests/cypress/tests/server/delete_row_test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe('delete', () => {
1010
});
1111

1212
it('can delete row when sorted', () => {
13-
cy.get('tr th.column-0 .sort').last().click({ force: true });
13+
cy.get('tr th.column-0 .sort').last().click({ force: true }).click({ force: true });
1414
DashTable.getCell(0, 0).within(() => cy.get('.dash-cell-value').should('have.html', '28155'));
1515
DashTable.getDelete(0).click();
1616
DashTable.getCell(0, 0).within(() => cy.get('.dash-cell-value').should('have.html', '28154'));

Diff for: packages/dash-table/tests/cypress/tests/standalone/delete_row_test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe('delete', () => {
1010
});
1111

1212
it('can delete row when sorted', () => {
13-
cy.get('tr th.column-0 .sort').last().click({ force: true });
13+
cy.get('tr th.column-0 .sort').last().click({ force: true }).click({ force: true });
1414
DashTable.getCell(0, 0).within(() => cy.get('.dash-cell-value').should('have.html', '4999'));
1515
DashTable.getDelete(0).click();
1616
DashTable.getCell(0, 0).within(() => cy.get('.dash-cell-value').should('have.html', '4998'));

Diff for: packages/dash-table/tests/cypress/tests/standalone/select_row_test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('select row', () => {
1818
it('select, sort, new row is not selected', () => {
1919
DashTable.getSelect(0).within(() => cy.get('input').click());
2020
DashTable.getSelect(0).within(() => cy.get('input').should('be.checked'));
21-
cy.get('tr th.column-0 .sort').last().click({ force: true });
21+
cy.get('tr th.column-0 .sort').last().click({ force: true }).click({ force: true });
2222
DashTable.getSelect(0).within(() => cy.get('input').should('not.be.checked'));
2323
});
2424
});

Diff for: packages/dash-table/tests/cypress/tests/standalone/sorting_test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ describe('sort', () => {
1111
DashTable.getCell(2, 6).within(() => cy.get('.Select-value-label').should('have.html', 'Tropical Beaches'));
1212
DashTable.getCell(3, 6).within(() => cy.get('.Select-value-label').should('have.html', 'Humid'));
1313
cy.get('tr th.column-6 .sort').last().click();
14-
DashTable.getCell(0, 6).within(() => cy.get('.Select-value-label').should('have.html', 'Wet'));
15-
DashTable.getCell(1, 6).within(() => cy.get('.Select-value-label').should('have.html', 'Wet'));
16-
DashTable.getCell(2, 6).within(() => cy.get('.Select-value-label').should('have.html', 'Wet'));
17-
DashTable.getCell(3, 6).within(() => cy.get('.Select-value-label').should('have.html', 'Wet'));
14+
DashTable.getCell(0, 6).within(() => cy.get('.Select-value-label').should('have.html', 'Humid'));
15+
DashTable.getCell(1, 6).within(() => cy.get('.Select-value-label').should('have.html', 'Humid'));
16+
DashTable.getCell(2, 6).within(() => cy.get('.Select-value-label').should('have.html', 'Humid'));
17+
DashTable.getCell(3, 6).within(() => cy.get('.Select-value-label').should('have.html', 'Humid'));
1818
});
1919
});

0 commit comments

Comments
 (0)