# As requested on the forum: https://community.plotly.com/t/issue-with-search-text-reset-in-dash-mantine-components-multiselect/89133
import dash_mantine_components as dmc
from dash import Dash, _dash_renderer, html, dcc, Input, Output, State, callback
_dash_renderer._set_react_version("18.2.0")
app = Dash(external_stylesheets=dmc.styles.ALL)
component = dmc.MultiSelect(
label="Pick your favorite libraries",
data=["Pandas", "NumPy", "TensorFlow", "PyTorch"],
searchable=True,
w=400,
id="select",
)
app.layout = dmc.MantineProvider([
dcc.Store(id="search"),
dmc.Title("Demo of dmc.MultiSelect searchValue: Keeping search text after item is selected", order=4, py="lg"),
html.Div(id="out"),
component
])
@callback(
Output("search", "data"),
Input("select", "searchValue")
)
def update(searchValue):
return searchValue
@callback(
Output("out", "children"),
Output("select", "searchValue"),
Input("select", "value"),
State("search", "data")
)
def update(val,search):
return f"You selected {val}", search