-
-
Notifications
You must be signed in to change notification settings - Fork 70
Closed
Description
Hi,
Using dash_mantine_components 1.1.1 & dash 3.0.2 :
When I initialize a dmc.Select component, without "value" and "data", inside a dmc.PopoverDropdown, the Select component becomes bugged after updating value and data inside a callback : the Select's dropdown doesn't appear and the value is empty. Sometimes i can get it to work by clicking elsewhere and then back on the Select.
Here is a minimal code example to reproduce the bug :
import dash_mantine_components as dmc
from dash import Dash, _dash_renderer, callback, Input, Output
_dash_renderer._set_react_version("18.2.0")
app = Dash(__name__)
app.layout = dmc.MantineProvider(
dmc.Center(
[
dmc.Stack(
[
dmc.Button(
"Update Select",
id="update-select"
),
dmc.Popover(
[
dmc.PopoverTarget(
dmc.Button(
"Toggle Popover"
)
),
dmc.PopoverDropdown(
dmc.Select(
label="Select your favorite library",
placeholder="Select one",
id="framework-select",
comboboxProps={"withinPortal": False}
),
p="sm",
w="fit-content"
),
]
),
]
)
],
style={"height": '100vh', "width": "100vw"}
)
)
@callback(
Output("framework-select", "value"),
Output("framework-select", "data"),
Input("update-select", "n_clicks"),
prevent_initial_call=True
)
def update_select(_):
value = "pd"
data = [
{"value": "pd", "label": "Pandas"},
{"value": "np", "label": "NumPy"},
{"value": "tf", "label": "TensorFlow"},
{"value": "torch", "label": "PyTorch"}
]
return value, data
if __name__ == "__main__":
app.run(debug=True)
Current workaround :
Initializing the dmc.Select component with a placeholder value and data is fixing the issue.
import dash_mantine_components as dmc
from dash import Dash, _dash_renderer, callback, Input, Output
_dash_renderer._set_react_version("18.2.0")
app = Dash(__name__)
app.layout = dmc.MantineProvider(
dmc.Center(
[
dmc.Stack(
[
dmc.Button(
"Update Select",
id="update-select"
),
dmc.Popover(
[
dmc.PopoverTarget(
dmc.Button(
"Toggle Popover"
)
),
dmc.PopoverDropdown(
dmc.Select(
label="Select your favorite library",
placeholder="Select one",
id="framework-select",
comboboxProps={"withinPortal": False},
data=["placeholder"],
value="placeholder"
),
p="sm",
w="fit-content"
),
]
),
]
)
],
style={"height": '100vh', "width": "100vw"}
)
)
@callback(
Output("framework-select", "value"),
Output("framework-select", "data"),
Input("update-select", "n_clicks"),
prevent_initial_call=True
)
def update_select(_):
value = "pd"
data = [
{"value": "pd", "label": "Pandas"},
{"value": "np", "label": "NumPy"},
{"value": "tf", "label": "TensorFlow"},
{"value": "torch", "label": "PyTorch"}
]
return value, data
if __name__ == "__main__":
app.run(debug=True)
Metadata
Metadata
Assignees
Labels
No labels