Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Checklist button doesn't select other checklist buttons properly on calling callbacks

I am trying to select multiple checklist buttons based on other single checklist button by using callback but it is not selecting after I deselect and reselect that particular button.
Here is the attached gif:
www_screencapture_com_2021-1-14_17_53

Here is the relevant code:

html.Div(
                        [
                            dbc.FormGroup(
                                [
                                    dbc.Label(
                                        "🌴 Filter by Preprocessing Functions to Apply:"
                                    ),
                                    dbc.Checklist(
                                        options=[
                                            {"label": "All", "value": "all"},
                                            {"label": "Customized", "value": "custom"},
                                        ],
                                        value="all",
                                        id="radio-button",
                                        inline=True,
                                        style={"padding": "10px"},
                                    ),
                                ]
                            ),
                            html.Div(
                                [
                                    dbc.FormGroup(
                                        [
                                            dbc.Checklist(
                                                id="checklist-button",
                                                options=[
                                                    {
                                                        "label": "remove_digits🔢",
                                                        "value": "remove_digits",
                                                    },
                                                    {
                                                        "label": "remove_accented_chars (Ñ)",
                                                        "value": "accented_char_removal",
                                                    },
                                                    {
                                                        "label": "lemmatize_the_text",
                                                        "value": "lemmatize_the_text",
                                                    },
                                                    {
                                                        "label": "remove_stopwords",
                                                        "value": "stop_words",
                                                    },
                                                ],
                                                value=[
                                                    "remove_digits",
                                                    "accented_char_removal",
                                                    "lemmatize_the_text",
                                                    "stop_words",
                                                ],
                                                switch=True,
                                            )
                                        ]
                                    )
                                ],
                                style={"padding": "5px", "margin-bottom": "10px",},
                            )

Callback for connecting both checklist:

@app.callback(Output("checklist-button", "value"), [Input("radio-button", "value")])
def display_status(selector):
    if selector == "all":
        return [
            "remove_digits",
            "lemmatize_the_text",
            "stop_words",
            "accented_char_removal",
        ]
    else:
        return []

I want if All button is selected any number of times after deselecting, the below all checklist buttons should be selected and if customized button is selected then none of the below buttons should be selected at first and user can select any particular buttons from below.

Hi @matsujju .

Just change ‘.Checklist’ for .'RadioItems’

RadioItems allow the user only choose one of the options.

1 Like