From bc5da0c2966495470d66cf51ff38a38d8898ef96 Mon Sep 17 00:00:00 2001 From: bprize15 Date: Mon, 18 Nov 2024 20:11:42 -0500 Subject: [PATCH 1/2] disable search bar when section hidden --- web/src/main/javascript/src/components/Header/Header.tsx | 2 +- web/src/main/javascript/src/components/SearchBar/SearchBar.tsx | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/web/src/main/javascript/src/components/Header/Header.tsx b/web/src/main/javascript/src/components/Header/Header.tsx index 951fa83..526057f 100644 --- a/web/src/main/javascript/src/components/Header/Header.tsx +++ b/web/src/main/javascript/src/components/Header/Header.tsx @@ -114,7 +114,7 @@ export default function Header({ }} > - +
Date: Tue, 19 Nov 2024 09:19:09 -0500 Subject: [PATCH 2/2] fix next/previous nav for mobile search results --- .../src/components/SearchBar/SearchBar.tsx | 56 ++++++++++--------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/web/src/main/javascript/src/components/SearchBar/SearchBar.tsx b/web/src/main/javascript/src/components/SearchBar/SearchBar.tsx index acfddb2..38dd519 100644 --- a/web/src/main/javascript/src/components/SearchBar/SearchBar.tsx +++ b/web/src/main/javascript/src/components/SearchBar/SearchBar.tsx @@ -304,6 +304,31 @@ export default function SearchBar({ ); } + const getPreviousResult = resultsAndIndexDefined + ? () => { + let newIndex = cancerTypeResults.length - 1; + if (cancerTypeResultsIndex !== 0) { + newIndex = cancerTypeResultsIndex - 1; + } + oncoTree?.focus(cancerTypeResults[newIndex]); + setCancerTypeResultsIndex(newIndex); + } + : undefined; + + const getNextResult = resultsAndIndexDefined + ? () => { + let newIndex = 0; + if ( + cancerTypeResultsIndex !== + cancerTypeResults.length - 1 + ) { + newIndex = cancerTypeResultsIndex + 1; + } + oncoTree?.focus(cancerTypeResults[newIndex]); + setCancerTypeResultsIndex(newIndex); + } + : undefined + return ( <> {getResultsNumberSpan()} @@ -312,18 +337,8 @@ export default function SearchBar({
{ - let newIndex = cancerTypeResults.length - 1; - if (cancerTypeResultsIndex !== 0) { - newIndex = cancerTypeResultsIndex - 1; - } - oncoTree?.focus(cancerTypeResults[newIndex]); - setCancerTypeResultsIndex(newIndex); - } - : undefined - } + onClick={mobileView ? undefined : getPreviousResult} + onTouchStart={mobileView ? getPreviousResult : undefined} > { - let newIndex = 0; - if ( - cancerTypeResultsIndex !== - cancerTypeResults.length - 1 - ) { - newIndex = cancerTypeResultsIndex + 1; - } - oncoTree?.focus(cancerTypeResults[newIndex]); - setCancerTypeResultsIndex(newIndex); - } - : undefined - } + onClick={mobileView ? undefined : getNextResult} + onTouchStart={mobileView ? getNextResult : undefined} >