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

Filter nil values before triggering initial layout callbacks. #81

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
has,
intersection,
isEmpty,
isNil,
keys,
lensPath,
merge,
Expand Down Expand Up @@ -80,6 +81,10 @@ function triggerDefaultState(dispatch, getState) {
getState().layout
);

if (isNil(propValue)) {
return;
}

dispatch(notifyObservers({
id: componentId,
props: {[componentProp]: propValue},
Expand Down
65 changes: 0 additions & 65 deletions tests/test_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -1682,71 +1682,6 @@ def callback(*args):
"input-{}, input-{}".format(i, i+1)
)

def test_generate_overlapping_outputs(self):
app = dash.Dash()
app.config['suppress_callback_exceptions'] = True
block = html.Div([

html.Div(id='input-1', children='input-1'),
html.Div(id='input-2', children='input-2'),
html.Div(id='input-3', children='input-3'),
html.Div(id='input-4', children='input-4'),
html.Div(id='input-5', children='input-5'),

html.Div(id='output-1'),
html.Div(id='output-2'),
html.Div(id='output-3'),
html.Div(id='output-4'),

])
app.layout = html.Div([
html.Div(id='input'),
html.Div(id='container')
])

call_counts = {
'container': Value('i', 0),
'output-1': Value('i', 0),
'output-2': Value('i', 0),
'output-3': Value('i', 0),
'output-4': Value('i', 0),
}

@app.callback(Output('container', 'children'),
[Input('input', 'children')])
def display_output(*args):
call_counts['container'].value += 1
return block

def generate_callback(outputid):
def callback(*args):
call_counts[outputid].value += 1
return '{}, {}'.format(*args)
return callback

for i in range(1, 5):
outputid = 'output-{}'.format(i)
app.callback(
Output(outputid, 'children'),
[Input('input-{}'.format(i), 'children'),
Input('input-{}'.format(i+1), 'children')]
)(generate_callback(outputid))

self.startServer(app)

wait_for(lambda: call_counts['container'].value == 1)
self.wait_for_element_by_css_selector('#output-1')
time.sleep(5)

for i in range(1, 5):
outputid = 'output-{}'.format(i)
self.assertEqual(call_counts[outputid].value, 1)
self.wait_for_text_to_equal(
'#{}'.format(outputid),
"input-{}, input-{}".format(i, i+1)
)
self.assertEqual(call_counts['container'].value, 1)

def test_update_react_version(self):
import dash_renderer

Expand Down