✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Clearing filters not removing text from filter row in Dash Datatable

I am entering filter queries with a separate input box. I see that I am able to successfully enter the query and it filters the table as expected. However, clearing the filter_query property on click of Clear Filter button does not remove text from the column filter.
In the below screenshot: Query is applied successfully.

After Clicking Clear Filters button - table is no longer filtered, but " eq Afghanistan" remains in column filter in table:

app.layout = html.Div([

    dcc.RadioItems(
        id='filter-query-read-write',
        options=[
            {'label': 'Read filter_query', 'value': 'read'},
            {'label': 'Write to filter_query', 'value': 'write'}
        ],
        value='read'
    ),

    html.Br(),

    dcc.Input(id='filter-query-input', placeholder='Enter filter query'),

    html.Div(id='filter-query-output'),

    html.Hr(),
    html.Button("Clear Filters", id="clear"),
    dash_table.DataTable(
        id='datatable-advanced-filtering',
        columns=[
            {'name': i, 'id': i, 'deletable': True} for i in df.columns
            # omit the id column
            if i != 'id'
        ],
        data=df.to_dict('records'),
        editable=True,
        page_action='native',
        page_size=10,
        filter_action="native"
    ),
    html.Hr(),
    html.Div(id='datatable-query-structure', style={'whitespace': 'pre'})
])

@app.callback(
    Output('datatable-advanced-filtering', 'filter_query'),
    [Input('filter-query-input', 'value'), Input('clear', 'n_clicks')]
)
def write_query(query, clicks):
    if clicks != None and clicks > 0:
        return ''
    else:
        if query is None or query == '':
            return ''
        return query

Any suggestions on how to fix this will be appreciated. Thank you!

this looks like a bug to me but i think that @Marc-Andre will know for sure.

thanks! please let me know if you have any suggestions on how to fix this issue.

Any update on how this issue can be fixed? Thank you!

Apologies for the long delay. This is a bug. Due to name similarities, I’ll assume you opened this issue in the repo: https://github.com/plotly/dash-table/issues/715. Looks like the issue is specific to clearing / emptying the filter. Changing the filter for another valid / not empty one updates correctly.

Thanks for confirming it is a bug. Are there any fixes I can do as workarounds?

There doesn’t seem to be a workaround way to clear it at the moment - only reacts to valid non-empty queries.