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

expose ReactDropdown prop closeOnSelect to python interface #983

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/components/Dropdown.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ Dropdown.propTypes = {
*/
multi: PropTypes.bool,

/**
* If true, dropdown menu closes when option is selected
*/
close_on_select: PropTypes.bool,

/**
* The grey, default text shown when no option is selected
*/
Expand Down Expand Up @@ -186,6 +191,7 @@ Dropdown.defaultProps = {
clearable: true,
disabled: false,
multi: false,
close_on_select: true,
searchable: true,
optionHeight: 35,
persisted_props: ['value'],
Expand Down
2 changes: 2 additions & 0 deletions src/fragments/Dropdown.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default class Dropdown extends Component {
id,
clearable,
multi,
close_on_select,
options,
setProps,
style,
Expand Down Expand Up @@ -94,6 +95,7 @@ export default class Dropdown extends Component {
setProps({value});
}
}}
closeOnSelect={close_on_select}
onInputChange={search_value => setProps({search_value})}
backspaceRemoves={clearable}
deleteRemoves={clearable}
Expand Down
4 changes: 1 addition & 3 deletions tests/dash_core_components_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ def is_month_valid(elem):
filtered = [_ for _ in days if _.text == str(day) and is_month_valid(_)]
if not filtered or len(filtered) > 1:
logger.error(
"cannot find the matched day with index=%s, day=%s",
index,
day,
"cannot find the matched day with index=%s, day=%s", index, day,
)
matched = filtered[0]
else:
Expand Down
13 changes: 3 additions & 10 deletions tests/integration/confirmdialog/test_confirm.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,14 @@ def on_click_confirm(n_clicks):

@app.callback(
Output("confirmed", "children"),
[
Input("confirm", "submit_n_clicks"),
Input("confirm", "cancel_n_clicks"),
],
[Input("confirm", "submit_n_clicks"), Input("confirm", "cancel_n_clicks"),],
[
State("confirm", "submit_n_clicks_timestamp"),
State("confirm", "cancel_n_clicks_timestamp"),
],
)
def on_confirmed(
submit_n_clicks,
cancel_n_clicks,
submit_timestamp,
cancel_timestamp,
submit_n_clicks, cancel_n_clicks, submit_timestamp, cancel_timestamp,
):
count.value += 1

Expand Down Expand Up @@ -102,8 +96,7 @@ def test_cnfd002_injected_confirm(dash_dcc):
)

@app.callback(
Output("confirm-container", "children"),
[Input("button", "n_clicks")],
Output("confirm-container", "children"), [Input("button", "n_clicks")],
)
def on_click(n_clicks):
if n_clicks:
Expand Down
6 changes: 1 addition & 5 deletions tests/integration/graph/test_graph_responsive.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ def test_grrs001_graph(dash_dcc, responsive, autosize, height, width, is_respons
figure=dict(
layout=dict(autosize=autosize, height=height, width=width),
data=[
dict(
x=[1, 2, 3, 4],
y=[5, 4, 3, 6],
line=dict(shape="spline"),
)
dict(x=[1, 2, 3, 4], y=[5, 4, 3, 6], line=dict(shape="spline"),)
],
),
)
Expand Down
20 changes: 4 additions & 16 deletions tests/integration/graph/test_graph_varia.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,15 @@ def test_grva002_graphs_with_different_figures(dash_dcc, is_eager):
)

@app.callback(
Output("restyle-data", "children"),
[Input("example-graph", "restyleData")],
Output("restyle-data", "children"), [Input("example-graph", "restyleData")],
)
def show_restyle_data(data):
if data is None: # ignore initial
return ""
return json.dumps(data)

@app.callback(
Output("relayout-data", "children"),
[Input("example-graph", "relayoutData")],
Output("relayout-data", "children"), [Input("example-graph", "relayoutData")],
)
def show_relayout_data(data):
if data is None or "autosize" in data: # ignore initial & auto width
Expand Down Expand Up @@ -351,12 +349,7 @@ def display_data(trigger, fig):
)

comparison = json.dumps(
[
dict(
x=[5, 6, 7, 8, 9, 10, 11],
y=[0.1, 0.2, 0.3, 0.4, 0.5, 0, 0.5],
)
]
[dict(x=[5, 6, 7, 8, 9, 10, 11], y=[0.1, 0.2, 0.3, 0.4, 0.5, 0, 0.5],)]
)
dash_dcc.wait_for_text_to_equal(
"#output_trace_will_prepend_with_max_points", comparison
Expand Down Expand Up @@ -521,12 +514,7 @@ def display_data(trigger, fig):
dash_dcc.wait_for_text_to_equal("#output_trace_will_extend_selectively", comparison)

comparison = json.dumps(
[
dict(
x=[3, 4, 5, 6, 7, 8, 9],
y=[0.5, 0, 0.1, 0.2, 0.3, 0.4, 0.5],
)
]
[dict(x=[3, 4, 5, 6, 7, 8, 9], y=[0.5, 0, 0.1, 0.2, 0.3, 0.4, 0.5],)]
)
dash_dcc.wait_for_text_to_equal(
"#output_trace_will_extend_with_max_points", comparison
Expand Down
12 changes: 2 additions & 10 deletions tests/integration/interval/test_interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ def test_intv002_restart(dash_dcc):
app = dash.Dash(__name__)
app.layout = html.Div(
[
dcc.Interval(
id="interval",
interval=100,
n_intervals=0,
max_intervals=-1,
),
dcc.Interval(id="interval", interval=100, n_intervals=0, max_intervals=-1,),
html.Button("Start", id="start", n_clicks_timestamp=-1),
html.Button("Stop", id="stop", n_clicks_timestamp=-1),
html.Div(id="output"),
Expand All @@ -45,10 +40,7 @@ def test_intv002_restart(dash_dcc):

@app.callback(
Output("interval", "max_intervals"),
[
Input("start", "n_clicks_timestamp"),
Input("stop", "n_clicks_timestamp"),
],
[Input("start", "n_clicks_timestamp"), Input("stop", "n_clicks_timestamp"),],
)
def start_stop(start, stop):
if start < stop:
Expand Down
5 changes: 1 addition & 4 deletions tests/integration/misc/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ def platter_app():
dcc.Input(value="", placeholder="type here", id="textinput"),
html.Label("Disabled Text Input"),
dcc.Input(
value="disabled",
type="text",
id="disabled-textinput",
disabled=True,
value="disabled", type="text", id="disabled-textinput", disabled=True,
),
html.Label("Slider"),
dcc.Slider(
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/store/test_component_props.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ def test_stcp002_modified_ts(store_app, dash_dcc):
)

@app.callback(
Output("initial-storage", "data"),
[Input("set-init-storage", "n_clicks")],
Output("initial-storage", "data"), [Input("set-init-storage", "n_clicks")],
)
def on_init(n_clicks):
if n_clicks is None:
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/tab/test_tabs_with_graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ def test_graph_does_not_resize_in_tabs(dash_dcc, is_eager):
)

@app.callback(
Output("tabs-content-example", "children"),
[Input("tabs-example", "value")],
Output("tabs-content-example", "children"), [Input("tabs-example", "value")],
)
def render_content(tab):
if tab == "tab-1-example":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ def load_data_by_type(filetype, contents):
def test_upft001_test_upload_with_different_file_types(filetype, dash_dcc):

filepath = os.path.join(
os.path.dirname(__file__),
"upload-assets",
"upft001.{}".format(filetype),
os.path.dirname(__file__), "upload-assets", "upft001.{}".format(filetype),
)

app = dash.Dash(__name__)
Expand Down