Bring Drag & Drop to Dash with Dashboard Engine. 💫 Learn how at our next webinar!

Can't get my button/input to sync with my value limit callback

Greetings, I have a dropdown input that fires off from a click of a button. I don’t want people to enter not more than 4 values. So I made a callback that reads the state of the dropdown input, and determines whether the length of values is >= 4. I want the input to stop working and a warning for users letting them know they have entered the max limit.

For some reason I’ve seen my code work very inconsistent with my syntax. For now consider it not working as intended, atleast my def limit() function part of my callback.

@app.callback(
    dash.dependencies.Output("input-warning", "children"),
    [dash.dependencies.Input("button_c", "n_clicks")],
    [dash.dependencies.State("dynamic-dropdown", "value")],
)
def update_multi_options(n_clicks, value):
    conn.rollback()
    if value is None:
        return PreventUpdate  
    else:
    # Make sure that the set values are in the option list, else they will disappear
    # from the shown select list, but still part of the `value`.
        return [
            o for o in OPTIONS if value.upper() in o["label"].upper() or o["value"] in (value or [])
        ]

@app.callback(
    [dash.dependencies.Output("input-warning","children"),
    dash.dependencies.Output("dynamic-dropdown", "options")],
    [dash.dependencies.Input("dynamic-dropdown", "value")]
    )
def limit(value):
    if value is None:
        return PreventUpdate
    elif len(value) >=4:
        children = html.P("limit reached",id='input-warning')
        return [children,[option for option in OPTIONS if option['value'] in value]] 

How can I solve for this?