fix: Return to empty search on 'Search' sidebar click (#12115)

* fix: Return to empty search on 'Search' sidebar click

* PR feedback
This commit is contained in:
Tom Moor
2026-04-19 15:53:19 -04:00
committed by GitHub
parent 666b3879b3
commit ce409c0a8a
+11
View File
@@ -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={<SearchIcon />}
label={t("Search")}
exact={false}
onClick={handleSearchClick}
/>
{can.createDocument && <DraftsLink />}
</Section>