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

Commit 390a499

Browse files
Merge branch 'master' of https://github.com/plotly/dash-core-components into unit_tests_with_jest
2 parents 7116f65 + b923e23 commit 390a499

File tree

7 files changed

+62
-11
lines changed

7 files changed

+62
-11
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1010
- Fixed bug with default Tabs value not being set to children's Tab value (if it's set)
1111
- Fixed bug where Tabs.children.props wheren't being selected properly, related to [#84](https://github.com/plotly/dash-renderer/issues/84)
1212

13+
## [0.33.1] -- 2018-10-17
14+
### Fixed
15+
- Fix Store component nested data [#333](https://github.com/plotly/dash-core-components/pull/333)
16+
1317
## [0.33.0] -- 2018-10-04
1418
### Added
1519

dash_core_components/dash_core_components.dev.js

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

dash_core_components/dash_core_components.min.js

Lines changed: 1 addition & 1 deletion
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: 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.33.0",
3+
"version": "0.33.1",
44
"description": "Core component suite for Dash",
55
"repository": {
66
"type": "git",

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

src/components/Store.react.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ function dataCheck(data, old) {
1313
return true;
1414
}
1515
for (let i = 0; i < data.length; i++) {
16-
if (data[i] !== old[i]) {
16+
if (dataCheck(data[i], old[i])) {
1717
return true;
1818
}
1919
}
2020
} else if (R.contains(type, ['String', 'Number'])) {
2121
return old !== data;
2222
} else if (type === 'Object') {
23-
return R.any(([k, v]) => old[k] !== v)(Object.entries(data));
23+
return R.any(([k, v]) => dataCheck(v, old[k]))(Object.entries(data));
2424
}
2525
return false;
2626
}

test/test_integration.py

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,19 +1173,19 @@ def test_storage_component(self):
11731173

11741174
app.layout = html.Div([
11751175
dcc.Store(id='storage',
1176-
storage_type='local'),
1176+
storage_type='local'),
11771177
html.Button('click me', id='btn'),
11781178
html.Button('clear', id='clear-btn'),
11791179
html.Button('set-init-storage',
11801180
id='set-init-storage'),
11811181
dcc.Store(id='dummy',
1182-
storage_type='session',
1183-
data=dummy_data),
1182+
storage_type='session',
1183+
data=dummy_data),
11841184
dcc.Store(id='memory',
1185-
storage_type='memory'),
1185+
storage_type='memory'),
11861186
html.Div(id='memory-output'),
11871187
dcc.Store(id='initial-storage',
1188-
storage_type='session'),
1188+
storage_type='session'),
11891189
html.Div(id='init-output')
11901190
])
11911191

@@ -1269,3 +1269,50 @@ def init_output(ts, data):
12691269
self.assertAlmostEqual(ts, init.get('ts'), delta=1000)
12701270
self.assertEqual('initialized', init.get('data'))
12711271

1272+
def test_store_nested_data(self):
1273+
app = dash.Dash(__name__)
1274+
1275+
nested = {'nested': {'nest': 'much'}}
1276+
nested_list = dict(my_list=[1, 2, 3])
1277+
1278+
app.layout = html.Div([
1279+
dcc.Store(id='store', storage_type='local'),
1280+
html.Button('set object as key', id='obj-btn'),
1281+
html.Button('set list as key', id='list-btn'),
1282+
html.Output(id='output')
1283+
])
1284+
1285+
@app.callback(Output('store', 'data'),
1286+
[Input('obj-btn', 'n_clicks_timestamp'),
1287+
Input('list-btn', 'n_clicks_timestamp')])
1288+
def on_obj_click(obj_ts, list_ts):
1289+
if obj_ts is None and list_ts is None:
1290+
raise PreventUpdate
1291+
1292+
# python 3 got the default props bug. plotly/dash#396
1293+
if (obj_ts and not list_ts) or obj_ts > list_ts:
1294+
return nested
1295+
else:
1296+
return nested_list
1297+
1298+
@app.callback(Output('output', 'children'),
1299+
[Input('store', 'modified_timestamp')],
1300+
[State('store', 'data')])
1301+
def on_ts(ts, data):
1302+
if ts is None:
1303+
raise PreventUpdate
1304+
return json.dumps(data)
1305+
1306+
self.startServer(app)
1307+
1308+
obj_btn = self.wait_for_element_by_css_selector('#obj-btn')
1309+
list_btn = self.wait_for_element_by_css_selector('#list-btn')
1310+
1311+
obj_btn.click()
1312+
time.sleep(3)
1313+
self.wait_for_text_to_equal('#output', json.dumps(nested))
1314+
# it would of crashed the app before adding the recursive check.
1315+
1316+
list_btn.click()
1317+
time.sleep(3)
1318+
self.wait_for_text_to_equal('#output', json.dumps(nested_list))

0 commit comments

Comments
 (0)