I’m having issue with a drop-down not maintaining it’s value when controlled from a button.
In one utility file, I have a function which returns a html.Div().
def my_div(display):
return html.Div( id = "my-container",
children=[
html.Div(
children=[
dcc.Dropdown(
id="my-selector",
options=[
{"label": "x", "value": "x"},
{"label": "y", "value": "y"},
],
style={'display' : display},
persistence=True,
value= 'x',
clearable=False
)
],
style={"width": "250px", "marginLeft": "16px"}
),
],
className='filter-selector',
)
In another index file, I have the following callback.
@app.callback(
[Output('my-selector', 'value')],
[Input('update', 'n_clicks')]
)
def set_squashed_point(n_clicks):
if n_clicks >= 1:
return "y"
else:
return "x"
In the UI I have a button that when clicked, successfully calls the callback, so I expect the drop-down, my-selector, to change its value from x to y and say at y, but instead goes back to x. Why is that ??
How do I get my callback to set the dropdown and stay at the value which was set ?
I am really confused about this, and would like some help.