Skip to content

Commit

Permalink
🔨 Include value in triggered input list.
Browse files Browse the repository at this point in the history
  • Loading branch information
T4rk1n committed Feb 15, 2019
1 parent ef420a4 commit dad46cc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 6 additions & 2 deletions dash/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,15 +950,19 @@ def dispatch(self):
target_id = '{}.{}'.format(output['id'], output['property'])
args = []

flask.g.input_values = {
flask.g.input_values = input_values = {
'{}.{}'.format(x['id'], x['property']): x.get('value')
for x in inputs
}
flask.g.state_values = {
'{}.{}'.format(x['id'], x['property']): x.get('value')
for x in state
}
flask.g.triggered_inputs = body.get('changedPropIds')
changed_props = body.get('changedPropIds')
flask.g.triggered_inputs = [
{'prop_id': x, 'value': input_values[x]}
for x in changed_props
] if changed_props else []

for component_registration in self.callback_map[target_id]['inputs']:
args.append([
Expand Down
5 changes: 2 additions & 3 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,8 @@ def on_click(*args):
if not dash.callback_context.triggered:
raise PreventUpdate
trigger = dash.callback_context.triggered[0]
input_value = dash.callback_context.inputs.get(trigger)
return 'Just clicked {} for the {} time!'.format(
trigger.split('.')[0], input_value
trigger['prop_id'].split('.')[0], trigger['value']
)

self.startServer(app)
Expand All @@ -603,7 +602,7 @@ def on_click(*args):
self.wait_for_element_by_id(x) for x in btns
]

for i in range(1, 10):
for i in range(1, 5):
for j, btn in enumerate(btns):
btn_elements[j].click()
self.wait_for_text_to_equal(
Expand Down

0 comments on commit dad46cc

Please sign in to comment.