jmix-framework / jmix

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

Problem with URL changing in browser address bar when using urlQueryParameters in the menu #3420

Closed kartushev closed 1 month ago

kartushev commented 3 months ago

Environment

Jmix version: 2.2.3

Bug Description

If you add links to the same ListView with different ids and add urlQueryParameters to each of them, then when you navigate to these menu items, the URL does not change in the browser address bar. The added menu items are not highlighted also.

Steps To Reproduce

Open attached project, click on Active/Inactive Users in menu

Current Behavior

URL in the browser bar does not change (or changes for millisecond and returns) Selected menu item is highlighted

Expected Behavior

URL in the browser bar changes Selected menu item is highlighted

Sample Project

menu-routing.zip

KremnevDmitry commented 1 month ago

The problem was that after navigation on the server, asynchronous URL fetching was called to extract the location from it. Since the request is asynchronous, the location changes on the client-side have not yet occurred, fetching returned the previous URL, without URL query parameters at all.

Then an asynchronous location replacement function was called with new (empty) query parameters, at that moment the URL was already updated on the client-side. And during this replacement, the current value was erased.

Solution: use location not from fetched URL from client-side, but location from backend servlet.

SergeiAksenov2 commented 1 month ago

Tested on: 1) Jmix version: 2.3.999-SNAPSHOT Jmix Studio plugin version: 2.3.SNAPSHOT6711-233 IntelliJ version: IntelliJ IDEA 2023.3.7 (Community Edition) 2) Jmix version: 2.3.999-SNAPSHOT Jmix Studio plugin version: 2.3.SNAPSHOT6714-241 IntelliJ version: IntelliJ IDEA 2024.1.4 (Community Edition)

URL is changes correctly - Ok.