Problem with Dash 3.0.2 with dmc

Hi,

I have this simple test app:

import dash
from dash import Output, Input, html, dcc
import dash_mantine_components as dmc

app = dash.Dash(__name__)

app.layout = dmc.MantineProvider(html.Div([
    dmc.Menu(
        children=[
            dmc.MenuTarget(
                dmc.Button("Open Menu", id="menu-button")
            ),
            dmc.MenuDropdown([
                dmc.MenuItem("Click Me", id="menu-item")
            ]),
        ]
    )
]))

@app.callback(
    Output("menu-button", "children"),  
    Input("menu-item", "n_clicks"),
    prevent_initial_call=True
)
def handle_click(n):
    print(f"MenuItem clicked. n_clicks = {n}")
    return "Open Menu" 

if __name__ == "__main__":
    app.run(debug=True)

It works all fine and dandy with Dash 3.0.1 and dmc 1.1.1. But with Dash 3.0.2, after clicking for the first time, the callback does not trigger anymore. It seems that the new version Releases · plotly/dash changed something regarding this, but its too much for me to comprehend.

Hi @PlotlyDude

Thanks for reporting. This will be fixed in the next Dash release (3.0.3) thanks to @jinnyzor’ PR: allows for parents to listen to descendent updates by BSd3v · Pull Request #3268 · plotly/dash · GitHub

This will also require an update to DMC. In the meantime, you can fix it by setting dmc.Menu(keepMounted=True )

3 Likes