diff --git a/app/components/Sidebar/App.tsx b/app/components/Sidebar/App.tsx index f3c05b2b5b..296769dbb6 100644 --- a/app/components/Sidebar/App.tsx +++ b/app/components/Sidebar/App.tsx @@ -4,6 +4,7 @@ import { useEffect, useState, useCallback, useMemo } from "react"; import { DndProvider } from "react-dnd"; import { HTML5Backend } from "react-dnd-html5-backend"; import { useTranslation } from "react-i18next"; +import { useHistory } from "react-router-dom"; import styled from "styled-components"; import { metaDisplay } from "@shared/utils/keyboard"; import Scrollable from "~/components/Scrollable"; @@ -37,6 +38,15 @@ function AppSidebar() { const team = useCurrentTeam(); const user = useCurrentUser(); const can = usePolicy(team); + const history = useHistory(); + + const handleSearchClick = useCallback(() => { + const basePath = searchPath(); + const { pathname, search } = history.location; + if (pathname.startsWith(basePath) && (search || pathname !== basePath)) { + history.push(basePath); + } + }, [history]); useEffect(() => { void collections.fetchAll(); @@ -106,6 +116,7 @@ function AppSidebar() { icon={} label={t("Search")} exact={false} + onClick={handleSearchClick} /> {can.createDocument && }