Form submit redirect URL is keeping filter query parameters when all filters are removed

Created on 17 December 2021, almost 3 years ago
Updated 26 July 2023, over 1 year ago

Problem/Motivation

When the facets form filters are all removed, and the form is submitted, the redirect URL is keeping the facets filter query parameters.

The problem seems to be on this line: https://git.drupalcode.org/project/facets_form/-/blob/1.x/src/Form/Facet...

$form_state->setRedirectUrl($this->buildRedirectUrl());

Here, after detecting that there are no active filters (because all are removed from the facet), the buildRedirectUrl() method is called with $exclude_filters argument FALSE (meaning that no facet filters should be removed from the query). However, buildRedirectUrl() gets the query from the request, and the current request contains the facets filters, which are not being removed.

Steps to reproduce

1. Visit a search page with a facet form containing a checkbox and/or dropdown widget and select some options.
2. Submit the form.
3. After the page is reloaded, remove all filters and submit the form.
4. When the page is reloaded, all the removed filter options are selected (the filter query parameters are not removed from the URL)

Note: this issue only affects the submit button, the reset button is working as expected.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium keszthelyi Brussels

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024