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

Commit 5aa3962

Browse files
Merge pull request #279 from plotly/graph_resize_fix
Clone figure.layout so plotly.js doesn't mutate it
2 parents 8171a52 + 166f6c9 commit 5aa3962

File tree

5 files changed

+75
-5
lines changed

5 files changed

+75
-5
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.28.2] - 2018-09-07
6+
### Fixed
7+
- Fixed bug where Graph would resize randomly when rerendered, for example in a dcc.Tabs component.
8+
59
## [0.28.2] - 2018-09-06
610
### Fixed
711
- Fixed bug in Tabs component where initial tab content wasn't rendering, [#282](https://github.com/plotly/dash-core-components/issues/282)

dash_core_components/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.28.1",
3+
"version": "0.28.2",
44
"description": "Core component suite for Dash",
55
"repository": {
66
"type": "git",

dash_core_components/version.py

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

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.28.2",
3+
"version": "0.28.3",
44
"description": "Core component suite for Dash",
55
"repository": {
66
"type": "git",

test/test_integration.py

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
from selenium import webdriver
1717
from selenium.webdriver.common.keys import Keys
1818
from selenium.common.exceptions import InvalidElementStateException
19+
from selenium.webdriver.common.by import By
20+
from selenium.webdriver.support.ui import WebDriverWait
21+
from selenium.webdriver.support import expected_conditions as EC
1922

2023
from textwrap import dedent
2124
try:
@@ -445,8 +448,6 @@ def render_content(tab):
445448

446449
self.startServer(app=app)
447450

448-
self.snapshot('tabs - without children')
449-
450451
initial_tab = self.wait_for_element_by_css_selector('#tab-2')
451452
tabs_content = self.wait_for_element_by_css_selector('#tabs-content')
452453
self.assertEqual(tabs_content.text, 'Test content 2')
@@ -574,6 +575,71 @@ def render_content(tab):
574575

575576
self.snapshot('Tab 1 should be selected by default')
576577

578+
def test_graph_does_not_resize_in_tabs(self):
579+
app = dash.Dash(__name__)
580+
app.layout = html.Div([
581+
html.H1('Dash Tabs component demo'),
582+
dcc.Tabs(id="tabs-example", value='tab-1-example', children=[
583+
dcc.Tab(label='Tab One', value='tab-1-example', id='tab-1'),
584+
dcc.Tab(label='Tab Two', value='tab-2-example', id='tab-2'),
585+
]),
586+
html.Div(id='tabs-content-example')
587+
])
588+
589+
@app.callback(Output('tabs-content-example', 'children'),
590+
[Input('tabs-example', 'value')])
591+
def render_content(tab):
592+
if tab == 'tab-1-example':
593+
return html.Div([
594+
html.H3('Tab content 1'),
595+
dcc.Graph(
596+
id='graph-1-tabs',
597+
figure={
598+
'data': [{
599+
'x': [1, 2, 3],
600+
'y': [3, 1, 2],
601+
'type': 'bar'
602+
}]
603+
}
604+
)
605+
])
606+
elif tab == 'tab-2-example':
607+
return html.Div([
608+
html.H3('Tab content 2'),
609+
dcc.Graph(
610+
id='graph-2-tabs',
611+
figure={
612+
'data': [{
613+
'x': [1, 2, 3],
614+
'y': [5, 10, 6],
615+
'type': 'bar'
616+
}]
617+
}
618+
)
619+
])
620+
self.startServer(app=app)
621+
622+
tab_one = self.wait_for_element_by_css_selector('#tab-1')
623+
tab_two = self.wait_for_element_by_css_selector('#tab-2')
624+
625+
WebDriverWait(self.driver, 10).until(
626+
EC.element_to_be_clickable((By.ID, "tab-2"))
627+
)
628+
629+
self.snapshot("Tabs with Graph - initial (graph should not resize)")
630+
tab_two.click()
631+
632+
self.snapshot("Tabs with Graph - clicked tab 2 (graph should not resize)")
633+
634+
WebDriverWait(self.driver, 10).until(
635+
EC.element_to_be_clickable((By.ID, "tab-1"))
636+
)
637+
638+
tab_one.click()
639+
640+
self.snapshot("Tabs with Graph - clicked tab 1 (graph should not resize)")
641+
642+
577643
def test_location_link(self):
578644
app = dash.Dash(__name__)
579645

0 commit comments

Comments
 (0)