Skip to content

fix(search): normalize the URL without stacking a history entry - #530

Merged
caro3801 merged 5 commits into
mainfrom
fix/back-to-insights-link
Oct 5, 2026
Merged

caro3801 merged 5 commits into
mainfrom
fix/back-to-insights-link

Conversation

@caro3801

@caro3801 caro3801 commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

fixes ICIJ/datashare#2431
fixes ICIJ/datashare#2436

Bug fix

Landing on the search page with a bare query (e.g. from the magnifying glass of Insights > Paths) made the view mirror its settings into the URL with a router.push, so the browser's back button led back to the search page instead of the page the user came from.

A new fillSearchRouteQuery guard, last in the search route's beforeEnter, adds the missing search params (sort, order, perPage, from...) from the store with a redirect, which creates no history entry. The view then has nothing to add: its mirror push targets the same URL and vue-router drops it as a duplicate navigation.

The regression spec (SearchSettings.spec.js) checks that window.history.length doesn't grow after landing on a bare query.

Side quests

  • Relevance sorted ascending on a bare query (bug: search sorts by relevance ascending when the URL has no order datashare#2436): checkSearchOrder forced order=asc when the URL had no order, so the least relevant documents came first. A missing or invalid order now falls back to the order from the search settings (desc by default).
  • Same Back trap on sibling pages: useUrlParamsWithStore compared the URL and store arrays with !==, so it always set the store on mount. SearchSavedList and SearchHistoryList reset the page to 1 and pushed a history entry. Now compared with isEqual.
  • from=0 never reached the store: useUrlParamWithStore checked the URL value for truthiness, so Back to the first page left the store on the previous offset. Only an absent param is skipped now.
  • Spec hygiene: SearchSettings.spec.js unmounts its wrappers in afterEach, so a failing assertion can't leave Search subscribed to the shared hash history.

@caro3801 caro3801 self-assigned this Oct 2, 2026
@caro3801
caro3801 requested a review from a team October 2, 2026 17:05
@caro3801
caro3801 force-pushed the fix/back-to-insights-link branch from 064ac71 to d98d90e Compare October 5, 2026 06:54
Landing on the search page with a bare query (e.g. from the magnifying
glass of Insights > Paths) made the view mirror its settings into the
URL with a router.push, so the browser's back button led back to the
search page instead of the page the user came from.

A beforeEnter guard now adds the missing search params from the store
with a redirect, which creates no history entry. The view then has
nothing to add, and its mirror push targets the same URL, which
vue-router drops as a duplicate navigation.
@caro3801
caro3801 force-pushed the fix/back-to-insights-link branch from d98d90e to 356e4ab Compare October 5, 2026 07:44
…share#2436

checkSearchOrder forced order=asc on any search URL without an order,
so a bare query (e.g. from Insights > Paths) sorted by relevance listed
the least relevant documents first. A missing or invalid order now
falls back to the order from the search settings (desc by default).
…CIJ/datashare#2431

useUrlParamsWithStore compared two arrays with !==, so it always set the
store on mount when the URL carried its params. Setters with side
effects ran for nothing: SearchSavedList and SearchHistoryList reset
the page to 1, which pushed a history entry and broke the back button.
…2431

useUrlParamWithStore checked the URL value for truthiness, so from=0
(e.g. Back to the first page) never reached the store, which kept the
previous offset. Only an absent param is now skipped.

@pirhoo pirhoo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks!

@caro3801
caro3801 merged commit 5de47f5 into main Oct 5, 2026
4 checks passed
@caro3801
caro3801 deleted the fix/back-to-insights-link branch October 5, 2026 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: search sorts by relevance ascending when the URL has no order bug: 'back' to Insights' Paths fails

2 participants