Skip to content
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

fix-302 #323

Closed
wants to merge 1 commit into from
Closed

fix-302 #323

wants to merge 1 commit into from

Conversation

AnnMarieW
Copy link
Collaborator

@AnnMarieW AnnMarieW commented Sep 28, 2024

Ensure that the fix applied in also applies to both Select and MultiSelect components.

When updating the data prop in a Select or MultiSelect component in a callback, the value now correctly reflects only valid options.

Here is an app to verify:

import dash_mantine_components as dmc
from dash import Dash, Input, Output, _dash_renderer, callback, html

_dash_renderer._set_react_version("18.2.0")

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

grouped_data = [
        {
            "group": "Frontend",
            "items": [{"value": "react", "label": "React"}, {"value": "angular", "label": "Angular"}],
        },
        {
            "group": "Backend",
            "items": [{"value": "svelte", "label": "Svelte"}, {"value": "vue", "label": "Vue"}],
        },
    ]

select = html.Div(
    [
        dmc.MultiSelect(
            label="Multi Select  (grouped)",
            placeholder="Select multi",
            clearable=True,
            id="multi-select-grouped",
            w=200,
            mb=10,
            persistence=True,
        ),
        dmc.Text(id="multi-selected-value-grouped"),
        dmc.Select(
            label="Select  (grouped)",
            placeholder="Select one",
            clearable=True,
            id="select-grouped",
            w=200,
            mb=10,
            persistence=True,
        ),
        dmc.Text(id="selected-value-grouped"),

    ]
)

app.layout = dmc.MantineProvider(select)


@callback(
    Output("selected-value-grouped", "children"),
    Input("select-grouped", "value"),
)
def select_value(value):
    return value


@callback(
    Output("multi-selected-value-grouped", "children"),
    Input("multi-select-grouped", "value"),
)
def select_value(value):
    return value


@callback(
    Output("select-grouped", "data"),
    Input("select-grouped", "children"),
)
def populate_grouped_data(value):
    return grouped_data


@callback(
    Output("multi-select-grouped", "data"),
    Input("multi-select-grouped", "children"),
)
def populate_grouped_data(value):
    return grouped_data


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

@AnnMarieW AnnMarieW requested a review from snehilvj September 28, 2024 17:49
@AnnMarieW AnnMarieW marked this pull request as draft September 28, 2024 17:49
@AnnMarieW AnnMarieW removed the request for review from snehilvj September 28, 2024 17:50
@AnnMarieW AnnMarieW closed this Sep 28, 2024
@AnnMarieW AnnMarieW deleted the fix-302 branch September 28, 2024 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant