Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit 926f0fd

Browse files
Merge pull request #306 from plotly/hotfix-tabs
Fix Tabs and Tabs tests
2 parents b7c2e4a + 438d87d commit 926f0fd

File tree

9 files changed

+40
-24
lines changed

9 files changed

+40
-24
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [0.30.2] - 2018-09-21
6+
### Fixed
7+
- Fixed regression in Graph component where it wouldn't resize correctly [#256](https://github.com/plotly/dash-core-components/issues/256)
8+
59
## [0.30.1] - 2018-09-20
610
### Fixed
711
- Renamed `__init__.py` external_path to dash_core_components.min.js

dash_core_components/dash_core_components.min.js

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

dash_core_components/package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
{
22
"name": "dash-core-components",
3-
"version": "0.29.0",
3+
"version": "0.30.2",
44
"description": "Core component suite for Dash",
55
"repository": {
66
"type": "git",
77
"url": "git://github.com/plotly/dash-core-components.git"
88
},
99
"main": "src/index.js",
1010
"scripts": {
11-
"build-dev": "builder run clean-lib && builder run extract-metadata && builder run generate-python-classes && webpack -w --config=./config/webpack/webpack.config.dev.js",
12-
"build-dist": "builder run clean-lib && builder run extract-metadata && builder run generate-python-classes && cross-env NODE_ENV=production webpack --config=./config/webpack/webpack.config.dist.js",
13-
"copy-lib": "cp -f lib/* dash_core_components",
1411
"generate-python-classes": "python -c \"import dash; dash.development.component_loader.generate_classes('dash_core_components', 'dash_core_components/metadata.json');\"",
1512
"install-local": "npm run copy-lib && python setup.py install",
16-
"prepublish": "npm test && builder run build-dist && npm run copy-lib",
13+
"prepublish": "npm test && npm run build:js && npm run build:js-dev && npm run build:py",
1714
"publish-all": "npm publish && python setup.py sdist upload",
1815
"publish-pypi": "npm run prepublish && python setup.py sdist && twine upload --sign --skip-existing",
19-
"start": "./node_modules/.bin/builder run build-dev",
16+
"start": "webpack-serve ./webpack.serve.config.js --open",
2017
"test": "eslint src",
2118
"test-watch": "./node_modules/.bin/builder run test-frontend-watch",
2219
"test-debug": "./node_modules/.bin/builder run test-frontend-debug",
2320
"uninstall-local": "pip uninstall dash-core-components -y",
2421
"build:js": "webpack --mode production",
22+
"build:js-dev": "webpack --mode development",
2523
"build:py": "node ./extract-meta src/components > dash_core_components/metadata.json && cp package.json dash_core_components && npm run generate-python-classes"
2624
},
2725
"author": "Chris Parmer <[email protected]>",

dash_core_components/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.30.1'
1+
__version__ = '0.30.2'

package-lock.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.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dash-core-components",
3-
"version": "0.30.1",
3+
"version": "0.30.2",
44
"description": "Core component suite for Dash",
55
"repository": {
66
"type": "git",

src/components/Graph.react.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, {Component} from 'react';
22
import PropTypes from 'prop-types';
3-
import {contains, filter, has, isNil, type} from 'ramda';
3+
import {contains, filter, clone, has, isNil, type} from 'ramda';
44
/* global Plotly:true */
55

66
const filterEventData = (gd, eventData, event) => {
@@ -77,15 +77,13 @@ export default class PlotlyGraph extends Component {
7777
if (animate && this._hasPlotted && figure.data.length === gd.data.length) {
7878
return Plotly.animate(id, figure, animation_options);
7979
}
80-
return Plotly.react(id, figure.data, figure.layout, config).then(
81-
() => {
82-
if (!this._hasPlotted) {
83-
this.bindEvents();
84-
Plotly.Plots.resize(document.getElementById(id));
85-
this._hasPlotted = true;
86-
}
80+
return Plotly.react(id, figure.data, clone(figure.layout), config).then(() => {
81+
if (!this._hasPlotted) {
82+
this.bindEvents();
83+
Plotly.Plots.resize(document.getElementById(id));
84+
this._hasPlotted = true;
8785
}
88-
);
86+
});
8987
}
9088

9189
bindEvents() {

src/components/Tabs.react.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,20 +168,17 @@ export default class Tabs extends Component {
168168

169169
const amountOfTabs = this.props.children.length;
170170

171-
window.console.log('this.props.children', this.props.children);
172171
EnhancedTabs = this.props.children.map((child, index) => {
173172
// TODO: handle components that are not dcc.Tab components (throw error)
174173
// enhance Tab components coming from Dash (as dcc.Tab) with methods needed for handling logic
175174
let childProps;
176175

177-
window.console.log('child', child);
178176

179177
if (child.props.children) {
180178
// if props appears on .children, props are coming from Dash
181179
childProps = child.props.children.props;
182180
} else {
183181
// else props are coming from React (Demo.react.js)
184-
window.console.log('child props', child.props);
185182
childProps = child.props;
186183
}
187184

test/test_integration.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,10 +539,19 @@ def on_click(n_clicks):
539539

540540
button_one.click()
541541

542+
# wait for tabs to be loaded after clicking
543+
WebDriverWait(self.driver, 10).until(
544+
EC.visibility_of_element_located((By.CSS_SELECTOR, "#graph-one .main-svg"))
545+
)
546+
542547
self.snapshot("Tabs 1 rendered ")
543548

544549
button_two.click()
545-
time.sleep(1)
550+
551+
# wait for tabs to be loaded after clicking
552+
WebDriverWait(self.driver, 10).until(
553+
EC.visibility_of_element_located((By.CSS_SELECTOR, "#graph-two .main-svg"))
554+
)
546555

547556
self.snapshot("Tabs 2 rendered ")
548557

@@ -629,6 +638,11 @@ def render_content(tab):
629638
self.snapshot("Tabs with Graph - initial (graph should not resize)")
630639
tab_two.click()
631640

641+
# wait for Graph's internal svg to be loaded after clicking
642+
WebDriverWait(self.driver, 10).until(
643+
EC.visibility_of_element_located((By.CSS_SELECTOR, "#graph-2-tabs .main-svg"))
644+
)
645+
632646
self.snapshot("Tabs with Graph - clicked tab 2 (graph should not resize)")
633647

634648
WebDriverWait(self.driver, 10).until(
@@ -637,6 +651,11 @@ def render_content(tab):
637651

638652
tab_one.click()
639653

654+
# wait for Graph to be loaded after clicking
655+
WebDriverWait(self.driver, 10).until(
656+
EC.visibility_of_element_located((By.CSS_SELECTOR, "#graph-1-tabs .main-svg"))
657+
)
658+
640659
self.snapshot("Tabs with Graph - clicked tab 1 (graph should not resize)")
641660

642661

0 commit comments

Comments
 (0)