New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] dcc.Clipboard functionality broken in Notification component #2830
Comments
Thanks for reporting. I could replicate this with your example. Given that it's using the same version of dmc, it's reasonable to assume that it's caused by something that changed between Dash versions 2.14 and 2.15. I'm not sure what is causing the issue though. To narrow things down, I checked to see if it was because of @callback(
Output("notifications-container", "children"),
Input("notify", "n_clicks"),
prevent_initial_call=True,
)
def notify(n_clicks):
return dcc.Checklist(
[
{
"label": [
html.Span(dcc.Clipboard(title="copy", content="icon text", id="id1")),
html.Span("Python", style={"font-size": 15, "padding-left": 10}),
],
"value": "Python",
},
], labelStyle={"display": "flex", "align-items": "center"}
) Not sure what in the |
Hi @AnnMarieW, Thanks for the quick response. I noticed that it works fine with Dash callbacks. if (
!this.props.n_clicks ||
this.props.n_clicks === prevProps.n_clicks
) {
return;
} This behavior seems to have been added in PR #2652. |
That’s helpful - thanks @DavidKatz-il ! The question is why is it not registering the |
Here's another minimal app to narrow down the issue. In this one, I've replaced the So maybe it's a dmc issue? It might be due to it being in the from dash import Dash, html, callback, Output, Input, dcc, dash
import dash_mantine_components as dmc
app = Dash(__name__, suppress_callback_exceptions=True)
app.layout = dmc.NotificationsProvider(
html.Div(
[
dmc.Text(children=dash.__version__),
dmc.Button("Show Notification", id="notify"),
html.Div(id="notifications-container"),
html.Div(id="container"),
]
),
)
@callback(
Output("notifications-container", "children"),
Input("notify", "n_clicks"),
prevent_initial_call=True,
)
def notify(n_clicks):
return dmc.Notification(
title="Notification",
autoClose=False,
id="simple-notify",
action="show",
message=f"{n_clicks=}",
icon=html.Button("click me", id="button"),
)
@callback(
Output("container", "children"),
Input("button", "n_clicks")
)
def update(n):
print("button n_clicks:", n)
return dash.no_update
if __name__ == "__main__":
app.run(debug=True)
|
Additionally, the same issue occurred with the from dash import Dash, html, callback, Output, Input, dcc, dash
import dash_mantine_components as dmc
@callback(
Output("notifications-container", "children"),
Input("notify", "n_clicks"),
prevent_initial_call=True,
)
def notify(n_clicks):
return dmc.Notification(
title="Notification",
autoClose=False,
id="simple-notify",
action="show",
message=dcc.Clipboard(title="copy", content="message text"),
)
app = Dash(__name__)
app.layout = dmc.NotificationsProvider(
html.Div(
[
dmc.Text(children=dash.__version__),
dmc.Button("Show Notification", id="notify"),
html.Div(id="notifications-container"),
html.Div(id="container"),
]
)
)
if __name__ == "__main__":
app.run(debug=True) |
Interesting, dmc must be doing something with the props and never receive the new n_clicks value in the onClick handler. |
The following code creates a notification using
dash_mantine_components.Notification
, with adcc.Clipboard
as its icon.Since
dash
version2.15.0
, the clipboard functionality appears to be broken.It seems that this issue is related to the following PR #2652.
pip list | grep dash
Is this issue related to
dash
or todash_mantine_components
?The text was updated successfully, but these errors were encountered: