Skip to content

Commit 5e62a48

Browse files
fix regression + basic test (#70)
* fix regression + basic test * build.watch, not test * remove .only on tests... * fix copy test * add back cypress issue comment * - copy/paste with sorting - delete cell with and w/o sorting - additional tests for copy/paste * - delete cell tests for sorted and sorted df * fix saving changes on click outside of cell * update changelog * fix useless propagates on click outside / blur
1 parent 5f616f9 commit 5e62a48

File tree

21 files changed

+394
-137
lines changed

21 files changed

+394
-137
lines changed

packages/dash-table/.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242

4343
- run:
4444
name: Run build:js
45-
command: npm run build:js
45+
command: npm run build:js-test
4646

4747
- run:
4848
name: Run build:py
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
2+
const path = require('path');
3+
const packagejson = require('./../../package.json');
4+
5+
const dashLibraryName = packagejson.name.replace(/-/g, '_');
6+
7+
module.exports = (preprocessor = {}, mode = 'development') => {
8+
console.log('********** Webpack Environment Overrides **********');
9+
console.log('Preprocessor', JSON.stringify(preprocessor));
10+
console.log('mode', mode);
11+
12+
return {
13+
entry: {
14+
bundle: './src/dash-table/index.ts',
15+
demo: ['./demo/index.js', './demo/index.html'],
16+
},
17+
mode: mode,
18+
output: {
19+
path: path.resolve(__dirname, './../..', dashLibraryName),
20+
filename: '[name].js',
21+
library: dashLibraryName,
22+
libraryTarget: 'window',
23+
},
24+
externals: {
25+
react: 'React',
26+
'react-dom': 'ReactDOM',
27+
'plotly.js': 'Plotly',
28+
},
29+
module: {
30+
rules: [
31+
{
32+
test: /demo[/]index.html?$/,
33+
loader: 'file-loader?name=index.[ext]'
34+
},
35+
{
36+
test: /\.ts(x?)$/,
37+
exclude: /node_modules/,
38+
loader: `babel-loader!ts-loader!webpack-preprocessor?${JSON.stringify(preprocessor)}`
39+
},
40+
{
41+
test: /\.js$/,
42+
exclude: /node_modules/,
43+
loader: `babel-loader!webpack-preprocessor?${JSON.stringify(preprocessor)}`
44+
45+
},
46+
{
47+
test: /\.css$/,
48+
use: [
49+
{ loader: 'style-loader' },
50+
{ loader: 'css-loader' }
51+
],
52+
},
53+
{
54+
test: /\.less$/,
55+
use: [
56+
{ loader: 'style-loader' },
57+
{ loader: 'css-loader' },
58+
{ loader: 'less-loader' }
59+
],
60+
},
61+
],
62+
},
63+
resolve: {
64+
alias: {
65+
'cypress': path.resolve('./tests/e2e/cypress/src'),
66+
'dash-table': path.resolve('./src/dash-table'),
67+
'core': path.resolve('./src/core'),
68+
'tests': path.resolve('./tests')
69+
},
70+
extensions: ['.js', '.ts', '.tsx']
71+
}
72+
};
73+
};
+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
declare module 'sheetclip' {
2-
const value: any;
2+
const value: {
3+
prototype: {
4+
parse: (text: string) => string[][];
5+
}
6+
};
7+
38
export default value;
49
}

packages/dash-table/CHANGELOG.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,12 @@
8585

8686
Default value is False.
8787

88-
## RC10 - Fix double click regression
88+
## RC10 - Fix double click regression
89+
90+
Issue: https://github.com/plotly/dash-table/issues/62
91+
92+
## RC11 - Fix copy/paste regression, fix delete regression, fix click/blur regression
93+
94+
Issue: https://github.com/plotly/dash-table/issues/64
95+
Issue: https://github.com/plotly/dash-table/issues/65
96+
Issue: https://github.com/plotly/dash-table/issues/67

packages/dash-table/dash_table/bundle.js

+3-3
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

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

packages/dash-table/dash_table/package.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dash-table",
3-
"version": "3.0.0rc10",
3+
"version": "3.0.0rc11",
44
"description": "Dash table",
55
"main": "build/index.js",
66
"scripts": {
@@ -20,12 +20,13 @@
2020
"private::test-e2e": "run-p --race private::host* private::runtests",
2121
"private::test-visual": "build-storybook && percy-storybook",
2222
"build.watch": "webpack-dev-server --content-base dash_table --mode development",
23-
"build:js-dev": "run-s \"private::build -- --mode development\"",
2423
"build:js": "run-s \"private::build -- --mode production\"",
24+
"build:js-dev": "run-s \"private::build -- --mode development\"",
25+
"build:js-test": "webpack --display-reasons --bail --config webpack.test.config.js",
2526
"build:py": "./extract-meta src/dash-table/Table.js > dash_table/metadata.json && cp package.json dash_table",
2627
"lint": "run-s private::lint.js private::lint.ts",
2728
"test": "run-s private::test-*",
28-
"test.watch": "run-p --race \"private::build -- --mode development --watch\" --race private::host* private::opentests"
29+
"test.watch": "run-p --race \"build:js-test -- --watch\" --race private::host* private::opentests"
2930
},
3031
"author": "Chris P <[email protected]",
3132
"license": "MIT",
@@ -69,7 +70,8 @@
6970
"wait-on": "^2.1.0",
7071
"webpack": "^4.8.3",
7172
"webpack-cli": "^2.1.3",
72-
"webpack-dev-server": "^3.1.5"
73+
"webpack-dev-server": "^3.1.5",
74+
"webpack-preprocessor": "^0.1.11"
7375
},
7476
"peerDependencies": {
7577
"react": ">=0.14",

packages/dash-table/npm-shrinkwrap.json

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

packages/dash-table/package.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dash-table",
3-
"version": "3.0.0rc10",
3+
"version": "3.0.0rc11",
44
"description": "Dash table",
55
"main": "build/index.js",
66
"scripts": {
@@ -20,12 +20,13 @@
2020
"private::test-e2e": "run-p --race private::host* private::runtests",
2121
"private::test-visual": "build-storybook && percy-storybook",
2222
"build.watch": "webpack-dev-server --content-base dash_table --mode development",
23-
"build:js-dev": "run-s \"private::build -- --mode development\"",
2423
"build:js": "run-s \"private::build -- --mode production\"",
24+
"build:js-dev": "run-s \"private::build -- --mode development\"",
25+
"build:js-test": "webpack --display-reasons --bail --config webpack.test.config.js",
2526
"build:py": "./extract-meta src/dash-table/Table.js > dash_table/metadata.json && cp package.json dash_table",
2627
"lint": "run-s private::lint.js private::lint.ts",
2728
"test": "run-s private::test-*",
28-
"test.watch": "run-p --race \"private::build -- --mode development --watch\" --race private::host* private::opentests"
29+
"test.watch": "run-p --race \"build:js-test -- --watch\" --race private::host* private::opentests"
2930
},
3031
"author": "Chris P <[email protected]",
3132
"license": "MIT",
@@ -69,7 +70,8 @@
6970
"wait-on": "^2.1.0",
7071
"webpack": "^4.8.3",
7172
"webpack-cli": "^2.1.3",
72-
"webpack-dev-server": "^3.1.5"
73+
"webpack-dev-server": "^3.1.5",
74+
"webpack-preprocessor": "^0.1.11"
7375
},
7476
"peerDependencies": {
7577
"react": ">=0.14",

packages/dash-table/src/core/Clipboard.ts

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
export default class Clipboard {
2+
/*#if TEST_COPY_PASTE*/
3+
private static value: string;
4+
/*#endif*/
5+
26
public static set(value: string): void {
7+
/*#if TEST_COPY_PASTE*/
8+
Clipboard.value = value;
9+
/*#endif*/
10+
311
const el = document.createElement('textarea');
412
el.value = value;
513

@@ -34,9 +42,17 @@ export default class Clipboard {
3442
}
3543
}
3644

37-
public static get(ev: ClipboardEvent) {
38-
return ev.clipboardData ?
39-
ev.clipboardData.getData('text/plain') :
45+
public static get(_ev: ClipboardEvent) {
46+
let value;
47+
48+
/*#if TEST_COPY_PASTE*/
49+
value = Clipboard.value;
50+
/*#else*/
51+
value = _ev.clipboardData ?
52+
_ev.clipboardData.getData('text/plain') :
4053
undefined;
54+
/*#endif*/
55+
56+
return value;
4157
}
4258
}

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

+17-16
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,13 @@ export default class Cell extends Component<ICellProps, ICellState> {
126126
onDoubleClick: onDoubleClick
127127
};
128128

129-
return !active ?
129+
return (!active && this.state.value === this.props.value) ?
130130
this.renderValue(attributes) :
131131
(<input
132132
ref='textInput'
133133
type='text'
134134
value={this.state.value}
135+
onBlur={this.propagateChange}
135136
onChange={this.handleChange}
136137
onKeyDown={this.handleKeyDown}
137138
onPaste={this.onPaste}
@@ -232,12 +233,8 @@ export default class Cell extends Component<ICellProps, ICellState> {
232233
</td>);
233234
}
234235

235-
handleChange = (e: any) => {
236-
this.setState({ value: e.target.value });
237-
}
238-
239-
handleKeyDown = (e: KeyboardEvent) => {
240-
if (e.keyCode !== KEY_CODES.ENTER) {
236+
propagateChange = () => {
237+
if (this.state.value === this.props.value) {
241238
return;
242239
}
243240

@@ -250,6 +247,18 @@ export default class Cell extends Component<ICellProps, ICellState> {
250247
} as any);
251248
}
252249

250+
handleChange = (e: any) => {
251+
this.setState({ value: e.target.value });
252+
}
253+
254+
handleKeyDown = (e: KeyboardEvent) => {
255+
if (e.keyCode !== KEY_CODES.ENTER) {
256+
return;
257+
}
258+
259+
this.propagateChange();
260+
}
261+
253262
handleOpenDropdown = () => {
254263
const { dropdown, td }: { [key: string]: any } = this.refs;
255264

@@ -287,7 +296,7 @@ export default class Cell extends Component<ICellProps, ICellState> {
287296
}
288297

289298
componentDidUpdate() {
290-
const { active, onChange, value } = this.propsWithDefaults;
299+
const { active } = this.propsWithDefaults;
291300

292301
if (active && this.refs.textInput) {
293302
(this.refs.textInput as HTMLElement).focus();
@@ -296,14 +305,6 @@ export default class Cell extends Component<ICellProps, ICellState> {
296305
if (active && this.refs.dropdown) {
297306
(this.refs.td as HTMLElement).focus();
298307
}
299-
300-
if (!active && this.state.value !== value) {
301-
onChange({
302-
target: {
303-
value: this.state.value
304-
}
305-
} as any);
306-
}
307308
}
308309

309310
shouldComponentUpdate(nextProps: ICellPropsWithDefaults, nextState: ICellState) {

0 commit comments

Comments
 (0)