From c434c0c0226473ff1e36eb8dec01576cfe7097fb Mon Sep 17 00:00:00 2001 From: "Erin E. Sullivan" Date: Wed, 7 Feb 2024 09:41:43 -0500 Subject: [PATCH 1/2] Wrapping history change in conditional instead of by browsing. --- src/modules/search/components/SearchBox/index.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/modules/search/components/SearchBox/index.js b/src/modules/search/components/SearchBox/index.js index a5b845e2a..cd7f293f8 100644 --- a/src/modules/search/components/SearchBox/index.js +++ b/src/modules/search/components/SearchBox/index.js @@ -109,16 +109,15 @@ function SearchBox ({ history, match, location }) { const urlLocation = `/${match.params.datastoreSlug}${browseOption ? `/browse/${dropdownOption.replace('browse_by_', '')}` : ''}?${newURL}`; - // Redirect users if browse option has been submitted - if (browseOption) { - window.location.href = urlLocation; + // If not browsing + if (!browseOption) { + // Do not submit if query remains unchanged + if (query === newQuery) return; + // Submit new search + history.push(urlLocation); } - // Do not submit if query remains unchanged - if (query === newQuery) return; - - // Submit new search - history.push(urlLocation); + window.location.href = urlLocation; } return ( From 66b0bd8e7abb9d8d50011a1b73461b77562a7c36 Mon Sep 17 00:00:00 2001 From: "Erin E. Sullivan" Date: Wed, 7 Feb 2024 15:09:42 -0500 Subject: [PATCH 2/2] Wrapping URL changes in if/else statement. Location based on current `hostname`. --- .../search/components/SearchBox/index.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/modules/search/components/SearchBox/index.js b/src/modules/search/components/SearchBox/index.js index cd7f293f8..8e69a10df 100644 --- a/src/modules/search/components/SearchBox/index.js +++ b/src/modules/search/components/SearchBox/index.js @@ -107,17 +107,22 @@ function SearchBox ({ history, match, location }) { format: 'RFC1738' }); - const urlLocation = `/${match.params.datastoreSlug}${browseOption ? `/browse/${dropdownOption.replace('browse_by_', '')}` : ''}?${newURL}`; - - // If not browsing - if (!browseOption) { + // Redirect users if browse option has been submitted + if (browseOption) { + let href = 'https://browse.workshop.search.lib.umich.edu'; + if (window.location.hostname === 'search.lib.umich.edu') { + href = `/${match.params.datastoreSlug}/browse`; + } + if (window.location.hostname === 'localhost') { + href = 'http://localhost:4567'; + } + window.location.href = `${href}/${dropdownOption.replace('browse_by_', '')}?${newURL}`; + } else { // Do not submit if query remains unchanged if (query === newQuery) return; // Submit new search - history.push(urlLocation); + history.push(`/${match.params.datastoreSlug}?${newURL}`); } - - window.location.href = urlLocation; } return (