diff --git a/web/src/main/javascript/src/components/SearchBar/SearchBar.tsx b/web/src/main/javascript/src/components/SearchBar/SearchBar.tsx
index 31948bc..bb54d9e 100644
--- a/web/src/main/javascript/src/components/SearchBar/SearchBar.tsx
+++ b/web/src/main/javascript/src/components/SearchBar/SearchBar.tsx
@@ -226,7 +226,7 @@ export default function SearchBar({
}}
options={options}
components={{
- ClearIndicator,
+ ClearIndicator: (props) => ,
Control,
}}
styles={{
@@ -259,26 +259,31 @@ export default function SearchBar({
);
+ interface IClearIndicatorProps extends ClearIndicatorProps<
+ OncoTreeSearchOption,
+ false,
+ GroupBase
+> {
+ searchResults: D3OncoTreeNode[] | undefined,
+ searchResultsIndex: number | undefined
+ }
+
function ClearIndicator(
- props: ClearIndicatorProps<
- OncoTreeSearchOption,
- false,
- GroupBase
- >,
+ {searchResults, searchResultsIndex, ...props}: IClearIndicatorProps,
) {
const inputStyle = props.getStyles("input", { ...props, isHidden: false });
const inputColor = inputStyle.color ?? "black";
const clearIndicatorClass = css(props.getStyles("clearIndicator", props));
const resultsAndIndexDefined =
- cancerTypeResults !== undefined && cancerTypeResultsIndex !== undefined;
+ searchResults !== undefined && searchResultsIndex !== undefined;
function getResultsNumberSpan() {
if (!resultsAndIndexDefined) {
return undefined;
}
- if (cancerTypeResults.length === 0) {
+ if (searchResults.length === 0) {
return (
{`${cancerTypeResultsIndex + 1}/${cancerTypeResults.length}`}
+ >{`${searchResultsIndex + 1}/${searchResults.length}`}
);
}
@@ -306,13 +311,13 @@ export default function SearchBar({
return;
}
- let newIndex = cancerTypeResults.length - 1;
+ let newIndex = searchResults.length - 1;
if (cancerTypeResultsIndex !== 0) {
- newIndex = cancerTypeResultsIndex - 1;
+ newIndex = searchResultsIndex - 1;
}
- oncoTree?.focus(cancerTypeResults[newIndex]);
+ oncoTree?.focus(searchResults[newIndex]);
setCancerTypeResultsIndex(newIndex);
- }, [resultsAndIndexDefined, cancerTypeResults, cancerTypeResultsIndex]);
+ }, [resultsAndIndexDefined, searchResults, searchResultsIndex]);
const getNextResult = useCallback(() => {
if (!resultsAndIndexDefined) {
@@ -322,24 +327,26 @@ export default function SearchBar({
let newIndex = 0;
if (
cancerTypeResultsIndex !==
- cancerTypeResults.length - 1
+ searchResults.length - 1
) {
- newIndex = cancerTypeResultsIndex + 1;
+ newIndex = searchResultsIndex + 1;
}
- oncoTree?.focus(cancerTypeResults[newIndex]);
+ oncoTree?.focus(searchResults[newIndex]);
setCancerTypeResultsIndex(newIndex);
- }, [resultsAndIndexDefined, cancerTypeResults, cancerTypeResultsIndex]);
+ }, [resultsAndIndexDefined, searchResults, searchResultsIndex]);
+
+ const isMobile = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
return (
<>
{getResultsNumberSpan()}
- {resultsAndIndexDefined && cancerTypeResults.length > 0 && (
+ {resultsAndIndexDefined && searchResults.length > 0 && (