Skip to content

Commit

Permalink
fix multiple bugs on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
bprize15 committed Nov 21, 2024
1 parent 8a5c30b commit 48b9ca7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
15 changes: 8 additions & 7 deletions web/src/main/javascript/src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,16 @@ export default function Header({
flexShrink: 0,
alignItems: "center",
visibility: searchSectionHidden ? "hidden" : "unset",
pointerEvents: searchSectionHidden ? 'none' : 'unset'
}}
>
<SearchBySelect />
<SearchBar oncoTreeData={oncoTreeData} oncoTree={oncoTree} disabled={searchSectionHidden} />
<div style={{ marginRight: 20 }} />
<VersionSelect
onVersionChange={onVersionChange}
stats={treeStats}
/>
<SearchBySelect />
<SearchBar oncoTreeData={oncoTreeData} oncoTree={oncoTree} />
<div style={{ marginRight: 20 }} />
<VersionSelect
onVersionChange={onVersionChange}
stats={treeStats}
/>
</div>
)}
<div style={{ flexGrow: 1 }} />
Expand Down
25 changes: 13 additions & 12 deletions web/src/main/javascript/src/components/SearchBar/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export interface ISearchBarProps {
oncoTreeData: OncoTreeNode;
oncoTree: OncoTree | undefined;
mobileView?: boolean;
disabled?: boolean;
}

const NEXT_BUTTON_DATA_TYPE = "nextButton";
Expand All @@ -41,7 +40,6 @@ export default function SearchBar({
oncoTreeData,
oncoTree,
mobileView = false,
disabled = false,
}: ISearchBarProps) {
const [searchParams, setSearchParams] = useSearchParams();
const search = searchParams.get("search");
Expand Down Expand Up @@ -207,7 +205,6 @@ export default function SearchBar({
<ReactSelect
inputValue={input}
value={getSearchBarValue()}
isDisabled={disabled}
placeholder={
isValidField(field)
? SEARCH_BY_FIELD_INFO[field].searchBarPlaceHolder
Expand Down Expand Up @@ -304,20 +301,25 @@ export default function SearchBar({
);
}

const getPreviousResult = resultsAndIndexDefined
? () => {
let newIndex = cancerTypeResults.length - 1;
const getPreviousResult = useCallback(() => {
if (!resultsAndIndexDefined) {
return;
}

let newIndex = cancerTypeResults.length - 1;
if (cancerTypeResultsIndex !== 0) {
newIndex = cancerTypeResultsIndex - 1;
}
oncoTree?.focus(cancerTypeResults[newIndex]);
setCancerTypeResultsIndex(newIndex);
}, [resultsAndIndexDefined, cancerTypeResults, cancerTypeResultsIndex]);

Check warning on line 315 in web/src/main/javascript/src/components/SearchBar/SearchBar.tsx

View workflow job for this annotation

GitHub Actions / build

React Hook useCallback has unnecessary dependencies: 'cancerTypeResults' and 'cancerTypeResultsIndex'. Either exclude them or remove the dependency array. Outer scope values like 'cancerTypeResults' aren't valid dependencies because mutating them doesn't re-render the component

Check warning on line 315 in web/src/main/javascript/src/components/SearchBar/SearchBar.tsx

View workflow job for this annotation

GitHub Actions / build

React Hook useCallback has unnecessary dependencies: 'cancerTypeResults' and 'cancerTypeResultsIndex'. Either exclude them or remove the dependency array. Outer scope values like 'cancerTypeResults' aren't valid dependencies because mutating them doesn't re-render the component

const getNextResult = useCallback(() => {
if (!resultsAndIndexDefined) {
return;
}
: undefined;

const getNextResult = resultsAndIndexDefined
? () => {
let newIndex = 0;
let newIndex = 0;
if (
cancerTypeResultsIndex !==
cancerTypeResults.length - 1
Expand All @@ -326,8 +328,7 @@ export default function SearchBar({
}
oncoTree?.focus(cancerTypeResults[newIndex]);
setCancerTypeResultsIndex(newIndex);
}
: undefined
}, [resultsAndIndexDefined, cancerTypeResults, cancerTypeResultsIndex]);

Check warning on line 331 in web/src/main/javascript/src/components/SearchBar/SearchBar.tsx

View workflow job for this annotation

GitHub Actions / build

React Hook useCallback has unnecessary dependencies: 'cancerTypeResults' and 'cancerTypeResultsIndex'. Either exclude them or remove the dependency array. Outer scope values like 'cancerTypeResults' aren't valid dependencies because mutating them doesn't re-render the component

Check warning on line 331 in web/src/main/javascript/src/components/SearchBar/SearchBar.tsx

View workflow job for this annotation

GitHub Actions / build

React Hook useCallback has unnecessary dependencies: 'cancerTypeResults' and 'cancerTypeResultsIndex'. Either exclude them or remove the dependency array. Outer scope values like 'cancerTypeResults' aren't valid dependencies because mutating them doesn't re-render the component

return (
<>
Expand Down

0 comments on commit 48b9ca7

Please sign in to comment.