Skip to content

Commit 3bd604d

Browse files
3.0 copy paste regression (#48)
* fix copy/paste regression, FE-BE props events * fix copy paste regression - basic testing * remove console.log * undo useless changes * pylint * pylint * fix pr comment * fix pr comments * pylint * pylint
1 parent b65f1e9 commit 3bd604d

File tree

16 files changed

+194
-8921
lines changed

16 files changed

+194
-8921
lines changed

packages/dash-table/dash_table/bundle.js

Lines changed: 18 additions & 4394 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/dash-table/dash_table/demo.js

Lines changed: 18 additions & 4463 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/dash-table/dash_table/metadata.json

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,6 @@
6060
"required": false,
6161
"description": ""
6262
},
63-
"update_on_unfocus": {
64-
"type": {
65-
"name": "bool"
66-
},
67-
"required": false,
68-
"description": "Only send an update of `dataframe_previous` and `dataframe_timestamp`\nwhen the cell is unfocused ()",
69-
"defaultValue": {
70-
"value": "true",
71-
"computed": false
72-
}
73-
},
7463
"dropdown_properties": {
7564
"type": {
7665
"name": "objectOf",

packages/dash-table/dash_table/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
{
22
"name": "dash-table",
3-
"version": "3.0.0rc3",
3+
"version": "3.0.0rc4",
44
"description": "Dash table",
55
"main": "build/index.js",
66
"scripts": {
77
"preprivate::opentests": "run-s private::wait*",
88
"preprivate::runtests": "run-s private::wait*",
99
"private::build": "webpack --display-reasons --bail",
10-
"private::host_dash": "python tests/e2e/dash/v_be_page.py",
10+
"private::host_dash8081": "python tests/e2e/dash/v_be_page.py",
11+
"private::host_dash8082": "python tests/e2e/dash/v_copy_paste.py",
1112
"private::host_js": "http-server ./dash_table -c-1 --silent",
12-
"private::wait_dash": "wait-on http://localhost:8081",
13+
"private::wait_dash8081": "wait-on http://localhost:8081",
14+
"private::wait_dash8082": "wait-on http://localhost:8082",
1315
"private::wait_js": "wait-on http://localhost:8080",
1416
"private::lint.js": "eslint src",
1517
"private::lint.ts": "tslint --project . src/**/*.ts",

packages/dash-table/npm-shrinkwrap.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/dash-table/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
{
22
"name": "dash-table",
3-
"version": "3.0.0rc3",
3+
"version": "3.0.0rc4",
44
"description": "Dash table",
55
"main": "build/index.js",
66
"scripts": {
77
"preprivate::opentests": "run-s private::wait*",
88
"preprivate::runtests": "run-s private::wait*",
99
"private::build": "webpack --display-reasons --bail",
10-
"private::host_dash": "python tests/e2e/dash/v_be_page.py",
10+
"private::host_dash8081": "python tests/e2e/dash/v_be_page.py",
11+
"private::host_dash8082": "python tests/e2e/dash/v_copy_paste.py",
1112
"private::host_js": "http-server ./dash_table -c-1 --silent",
12-
"private::wait_dash": "wait-on http://localhost:8081",
13+
"private::wait_dash8081": "wait-on http://localhost:8081",
14+
"private::wait_dash8082": "wait-on http://localhost:8082",
1315
"private::wait_js": "wait-on http://localhost:8080",
1416
"private::lint.js": "eslint src",
1517
"private::lint.ts": "tslint --project . src/**/*.ts",

packages/dash-table/src/dash-table/components/Cell.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,19 @@ export default class Cell extends Component<IProps, IState> {
101101
/>);
102102
}
103103

104+
private onPaste = (e: React.ClipboardEvent<Element>) => {
105+
const { onPaste } = this.propsWithDefaults;
106+
107+
onPaste(e);
108+
e.stopPropagation();
109+
}
110+
104111
private renderInput() {
105112
const {
106113
active,
107114
focused,
108115
onClick,
109-
onDoubleClick,
110-
onPaste
116+
onDoubleClick
111117
} = this.propsWithDefaults;
112118

113119
const classes = [
@@ -129,7 +135,7 @@ export default class Cell extends Component<IProps, IState> {
129135
type='text'
130136
value={this.state.value}
131137
onChange={this.handleChange}
132-
onPaste={onPaste}
138+
onPaste={this.onPaste}
133139
{...attributes}
134140
/>);
135141
}

packages/dash-table/src/dash-table/components/ControlledTable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ export default class ControlledTable extends Component {
509509
);
510510
setProps({
511511
dataframe: newDataframe,
512-
columns: newColumns,
512+
columns: newColumns
513513
});
514514
}
515515
}

packages/dash-table/src/dash-table/components/Table.js

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -55,32 +55,12 @@ export default class Table extends Component {
5555
<ControlledTable
5656
{...R.merge(this.props, {
5757
virtualizer: this.virtualizer,
58-
5958
setProps: newProps => {
59+
if (R.has('dataframe', newProps)) {
60+
const { dataframe } = this.props;
6061

61-
// !is_focused -> is_focused: save the current dataframe
62-
if (newProps.is_focused && !this.props.is_focused) {
63-
console.warn('Saving dataframe', this.props.dataframe);
64-
this.dataframe_previous = this.props.dataframe;
65-
}
66-
67-
// unfocused -> send the old dataframe and the update time
68-
if (!newProps.is_focused && this.props.is_focused &&
69-
this.props.update_on_unfocus) {
70-
console.warn('Updating timestamp');
71-
newProps.dataframe_timestamp = Date.now();
72-
newProps.dataframe_previous = this.dataframe_previous;
73-
74-
// table is unfocused but user copied and pasted data
75-
} else if (!this.props.is_focused &&
76-
R.has('dataframe', newProps)) {
77-
newProps.dataframe_previous = this.props.dataframe;
78-
newProps.dataframe_timestamp = Date.now();
79-
// user wants the new dataframe on every letter press
80-
} else if (!this.props.update_on_unfocus &&
81-
R.has('dataframe', newProps)) {
82-
newProps.dataframe_previous = this.dataframe_previous;
8362
newProps.dataframe_timestamp = Date.now();
63+
newProps.dataframe_previous = dataframe;
8464
}
8565

8666
this.props.setProps(newProps);
@@ -154,8 +134,7 @@ export const defaultProps = {
154134
th: {},
155135

156136
td: {},
157-
},
158-
update_on_unfocus: true
137+
}
159138
};
160139

161140
export const propTypes = {
@@ -165,11 +144,6 @@ export const propTypes = {
165144
dataframe: PropTypes.arrayOf(PropTypes.object),
166145
dataframe_previous: PropTypes.arrayOf(PropTypes.object),
167146
dataframe_timestamp: PropTypes.any,
168-
/**
169-
* Only send an update of `dataframe_previous` and `dataframe_timestamp`
170-
* when the cell is unfocused ()
171-
*/
172-
update_on_unfocus: PropTypes.bool,
173147

174148
dropdown_properties: PropTypes.objectOf(
175149
PropTypes.arrayOf(PropTypes.shape({
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import DashTable from 'cypress/DashTable';
2+
import DOM from 'cypress/DOM';
3+
import Key from 'cypress/Key';
4+
import Resolve from 'cypress/Resolve';
5+
6+
describe('copy paste', () => {
7+
beforeEach(() => {
8+
cy.visit('http://localhost:8082');
9+
});
10+
11+
it('can do BE roundtrip on cell modification', () => {
12+
DashTable.getCell(0, 0).click();
13+
DOM.focused.type(`1${Key.Enter}`);
14+
15+
DashTable
16+
.getCell(0, 0)
17+
.within(() => cy.get('.cell-value').should('have.html', '10'));
18+
19+
DashTable.getCell(0, 1)
20+
.within(() => cy.get('.cell-value').should('have.html', 'MODIFIED'));
21+
});
22+
23+
it('can do BE roundtrip on copy-paste', async () => {
24+
await Resolve(DashTable.getCell(0, 0).click());
25+
await Resolve(DOM.focused.type(`${Key.Control}c`));
26+
27+
await Resolve(DashTable.getCell(1, 0).click());
28+
await Resolve(DOM.focused.type(`${Key.Control}v`));
29+
30+
DashTable
31+
.getCell(1, 1)
32+
.within(() => cy.get('.cell-value').should('have.html', 'MODIFIED'));
33+
34+
});
35+
});

0 commit comments

Comments
 (0)