snehilvj / dash-mantine-components

Plotly Dash components based on Mantine React Components
https://www.dash-mantine-components.com
MIT License
582 stars 61 forks source link

[Bug] 'opened' seems to be always false #326

Closed kedingp closed 1 month ago

kedingp commented 1 month ago

After the change form 'in' to 'opened' for the Collapse keywords, the table seems to be initially unopened even if I set opened to True.

AnnMarieW commented 1 month ago

Can you please include an example that replicates the issue. It seems to word fine here:

Note - be sure to be on version >= 0.14.5

import dash_mantine_components as dmc
from dash import Dash, _dash_renderer, Input, Output
_dash_renderer._set_react_version("18.2.0")

app = Dash(external_stylesheets=dmc.styles.ALL)

app.layout = dmc.MantineProvider([
    dmc.Button("close", id="btn", n_clicks=0),
    dmc.Collapse( children=dmc.Text("this collapse starts closed"), opened=False, id="collapse", m=20),
    dmc.Divider(m=20, size="md"),
    dmc.Collapse( children=dmc.Text("This collapse is always open even at start"), opened=True, id="collapse2", m=20, )

])

@app.callback(
    Output("collapse", "opened"),
    Input("btn", "n_clicks"),
)
def update(n):
    if n% 2 == 0:
        return False
    return True

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

image

kedingp commented 1 month ago

Thanks a lot for your quick reply. The fault was on my end. I hadn't changed the respective callbacks from Output("collapse", "in") to Output("collapse", "opened") Your minimal example helped me finding this one. Thanks!