This repository was archived by the owner on Jun 3, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 143
Add search_value property to Dropdown #660
Merged
Merged
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7d06ed2
Add search_value property to Dropdown
inytar 929f337
Add intergity test to check that the search_value is updated
inytar 2ad14c8
Merge branch 'dev' into dropdown-search-value
byronz b20dbb4
Update tests/integration/dropdown/test_search_value.py
inytar 8add84b
Simplify search_value test
inytar 307bfd1
Merge branch 'dev' into dropdown-search-value
byronz 293b757
Simplify test further
inytar 7980fdf
Add test for dynamic options from server
inytar 62ab2b6
Merge branch 'dropdown-search-value' of github.com:wooga/dash-core-co…
inytar 78c9463
Reformat
inytar 3f57805
Make TCID unique
inytar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from multiprocessing import Value | ||
import dash | ||
from dash.dependencies import Input, Output, State | ||
import dash.testing.wait as wait | ||
import dash_core_components as dcc | ||
import dash_html_components as html | ||
|
||
|
||
def test_ddsv001_search_value(dash_duo): | ||
app = dash.Dash(__name__) | ||
app.layout = html.Div( | ||
[dcc.Dropdown(id="dropdown", search_value="something"), html.Div(id="output")] | ||
) | ||
|
||
call_count = Value("i", 0) | ||
|
||
@app.callback( | ||
Output("output", "children"), inputs=[Input("dropdown", "search_value")] | ||
) | ||
def update_output(search_value): | ||
call_count.value += 1 | ||
return 'search_value="{}"'.format(search_value) | ||
|
||
dash_duo.start_server(app) | ||
|
||
# Get the inner input used for search value. | ||
input_ = dash_duo.find_element("#dropdown input") | ||
|
||
# callback gets called with initial input | ||
wait.until(lambda: call_count.value == 1, timeout=1) | ||
|
||
dash_duo.wait_for_text_to_equal("#output", 'search_value="something"') | ||
|
||
input_.send_keys("x") | ||
wait.until(lambda: call_count.value == 2, timeout=1) | ||
dash_duo.wait_for_text_to_equal("#output", 'search_value="x"') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry, I missed this earlier - I think the test should use the same structure as the example app you gave, which is updating
options
fromsearch_value
in the same component. The reason this is important is (a) that's the primary use case for this prop, and (b) it will cause the dropdown to rerender, and we need to ensure that when it does the correct options are visible. I can certainly imagine errors in the component where on render it loses focus, or for some other reason it stops displaying the option list.(BTW nota big deal but you can probably get rid of all the
call_count
stuff, that doesn't really matter for this test, we only care about what's going on within the browser)