From 5605bab2c22729465a1cbf33e8524bcce2e1add3 Mon Sep 17 00:00:00 2001 From: Keegan George Date: Wed, 27 Nov 2024 03:26:25 +0900 Subject: [PATCH] FIX: Preserve history when routing to `/filter` route (#29929) --- .../javascripts/discourse/app/routes/discovery-filter.js | 7 ++++--- config/locales/client.en.yml | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse/app/routes/discovery-filter.js b/app/assets/javascripts/discourse/app/routes/discovery-filter.js index fdb817bb581..0cc5c136df8 100644 --- a/app/assets/javascripts/discourse/app/routes/discovery-filter.js +++ b/app/assets/javascripts/discourse/app/routes/discovery-filter.js @@ -1,10 +1,11 @@ import { setTopicList } from "discourse/lib/topic-list-tracker"; +import { escapeExpression } from "discourse/lib/utilities"; import DiscourseRoute from "discourse/routes/discourse"; import { i18n } from "discourse-i18n"; export default class DiscoveryFilterRoute extends DiscourseRoute { queryParams = { - q: { replace: true, refreshModel: true }, + q: { refreshModel: true }, }; async model(data) { @@ -19,7 +20,7 @@ export default class DiscoveryFilterRoute extends DiscourseRoute { } titleToken() { - const filterText = i18n("filters.filter.title"); - return i18n("filters.with_topics", { filter: filterText }); + const query = this.paramsFor(this.routeName).q; + return i18n("filters.filter.title", { filter: escapeExpression(query) }); } } diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 936e7475060..eaef3cbaf38 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -4352,7 +4352,7 @@ en: with_topics: "%{filter} topics" with_category: "%{filter} %{category} topics" filter: - title: "Filter" + title: "Filtered results for %{filter}" button: label: "Filter" latest: