jmix-framework / jmix

Jmix framework
https://www.jmix.io
Apache License 2.0
693 stars 124 forks source link

Only last change to UrlQueryParametersFacet is applied #3801

Open alferink opened 1 month ago

alferink commented 1 month ago

Environment

Jmix version: 2.3.4

Bug Description

I have multiple binders in a UrlQueryParametersFacet.

        <urlQueryParameters>
            <propertyFilter component="nameFilter"/>
            <genericFilter component="genericFilter"/>
            <pagination component="pagination"/>
        </urlQueryParameters>

When many binders change the url, only the last change is applied. So when I change the property filter and then the pagination, only the parameters maxResults und firstResult are in the url, but nameFilter is not.

Analysis

In UrlQueryParametersFacetImpl.onComponentQueryParametersChanged the new QueryParameters are set in the url. The current url is loaded using routeSupport.getActiveViewLocation(ui). It seems that it return url when the view was initially loaded. Any changes made to the URL in the meantime are therefore lost.

Steps To Reproduce

Use the attached sample project to reproduce the issue:

  1. Login as admin/admin
  2. Open Customers (CustomerListView)
  3. Filter by "1" (property filter for name) Url: http://localhost:8080/customers?nameFilter=contains_1
  4. Go to next page Url: http://localhost:8080/customers?maxResults=50&firstResult=50

Current Behavior

After Paging the filter parameter in the url has disapeared.

Expected Behavior

All parameters should still be in the url the Url should be http://localhost:8080/customers?maxResults=50&firstResult=50&nameFilter=contains_1

Sample Project

query-param-demo.zip