Skip to content

Commit f523cb7

Browse files
committed
persist callback graph layout when callbacks fire
1 parent 02d06ba commit f523cb7

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

dash-renderer/src/reducers/profile.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ const defaultProfile = {
2121
const defaultState = {
2222
updated: [],
2323
resources: {},
24-
callbacks: {}
24+
callbacks: {},
25+
graphLayout: null
2526
};
2627

2728
const profile = (state = defaultState, action) => {
@@ -36,7 +37,8 @@ const profile = (state = defaultState, action) => {
3637
const newState = {
3738
updated: [id],
3839
resources: state.resources,
39-
callbacks: state.callbacks
40+
callbacks: state.callbacks,
41+
graphLayout: state.graphLayout
4042
};
4143

4244
newState.callbacks[id] =

tests/integration/devtools/test_devtools_ui.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def test_dvui003_callback_graph(dash_duo):
8989
cbProfiles[k].network.time = 33;
9090
cbProfiles[k].total = 77;
9191
});
92-
"""
92+
"""
9393
)
9494

9595
dash_duo.find_element(".dash-debug-menu").click()
@@ -99,3 +99,28 @@ def test_dvui003_callback_graph(dash_duo):
9999
dash_duo.find_element('canvas[data-id="layer2-node"]')
100100

101101
dash_duo.percy_snapshot("devtools - callback graph", convert_canvases=True)
102+
103+
pos = dash_duo.driver.execute_script(
104+
"""
105+
const pos = store.getState().profile.graphLayout.positions['new-item.value'];
106+
pos.y -= 100;
107+
return pos.y;
108+
"""
109+
)
110+
111+
# hide and redraw the callback graph so we get the new position
112+
dash_duo.find_element(".dash-debug-menu__button--callbacks").click()
113+
dash_duo.find_element(".dash-debug-menu__button--callbacks").click()
114+
sleep(2)
115+
116+
# fire callbacks so the callback graph redraws again
117+
dash_duo.find_element("#add").click()
118+
dash_duo.wait_for_text_to_equal("#totals", "0 of 1 items completed - 0%")
119+
sleep(1)
120+
# the manually moved node is still in its new position
121+
assert pos == dash_duo.driver.execute_script(
122+
"""
123+
const pos = store.getState().profile.graphLayout.positions['new-item.value'];
124+
return pos.y;
125+
"""
126+
)

0 commit comments

Comments
 (0)