From a64c9f22550c7bb05986ab9040daca96e602a5b0 Mon Sep 17 00:00:00 2001 From: LautaroCesso <59095036+LautaroCesso@users.noreply.github.com> Date: Fri, 2 Oct 2020 02:17:22 -0300 Subject: [PATCH] Fix error in searchbox in tickets/search-tickets (#891) --- client/src/app/admin/panel/admin-panel-menu.js | 1 - client/src/lib-app/search-tickets-utils.js | 10 +++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/client/src/app/admin/panel/admin-panel-menu.js b/client/src/app/admin/panel/admin-panel-menu.js index 0e3c07d0..cc367d22 100644 --- a/client/src/app/admin/panel/admin-panel-menu.js +++ b/client/src/app/admin/panel/admin-panel-menu.js @@ -3,7 +3,6 @@ import _ from 'lodash'; import {connect} from 'react-redux'; import i18n from 'lib-app/i18n'; -import searchTicketsUtils from 'lib-app/search-tickets-utils'; import Menu from 'core-components/menu'; import queryString from 'query-string'; diff --git a/client/src/lib-app/search-tickets-utils.js b/client/src/lib-app/search-tickets-utils.js index ba3a5cc9..55f1b767 100644 --- a/client/src/lib-app/search-tickets-utils.js +++ b/client/src/lib-app/search-tickets-utils.js @@ -102,11 +102,15 @@ export default { getFiltersForURL(filtersWithShouldRemoveParams) { const shouldRemoveCustomParam = filtersWithShouldRemoveParams.shouldRemoveCustomParam ? filtersWithShouldRemoveParams.shouldRemoveCustomParam : false; const shouldRemoveUseInitialValuesParam = filtersWithShouldRemoveParams.shouldRemoveUseInitialValuesParam ? filtersWithShouldRemoveParams.shouldRemoveUseInitialValuesParam : false; - let filters = filtersWithShouldRemoveParams.filters; + const currentSearchParams = queryString.parse(window.location.search); + let filters = { + ...currentSearchParams, + ...filtersWithShouldRemoveParams.filters, + }; filters = { - ...queryString.parse(window.location.search), ...filters, + query: filters.query ? encodeURIComponent(filters.query) : filters.query }; if(shouldRemoveCustomParam) delete filters.custom; @@ -127,7 +131,7 @@ export default { else return query + `&${filter}=${JSON.stringify(value)}`; }, '').slice(1); - if(!_.isEqual(queryString.parse(`?${query}`), queryString.parse(window.location.search))) { + if(!_.isEqual(queryString.parse(`?${query}`), currentSearchParams)) { return `?${query}`; } },