Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

fix(photos):reset-search-input-after-navigation

Aswin Asoka5462ee32f40
diff --git a/web/apps/photos/src/components/SearchBar.tsx b/web/apps/photos/src/components/SearchBar.tsx
index 171141c2d3..17fc64e3c7 100644
--- a/web/apps/photos/src/components/SearchBar.tsx
+++ b/web/apps/photos/src/components/SearchBar.tsx
@@ -73,6 +73,15 @@ export const SearchBar: React.FC<SearchBarProps> = (props) => {
const isSmallWidth = useIsSmallWidth();
const [open, setOpen] = useState(false);
const [searchResetKey, setSearchResetKey] = useState(0);
+ const [previousIsInSearchMode, setPreviousIsInSearchMode] = useState(
+ props.isInSearchMode,
+ );
+
+ // Reset the kept-mounted input for every path that leaves an active search.
+ if (previousIsInSearchMode !== props.isInSearchMode) {
+ setPreviousIsInSearchMode(props.isInSearchMode);
+ if (previousIsInSearchMode) setSearchResetKey((key) => key + 1);
+ }
const shortcut =
typeof navigator !== "undefined" && /mac/i.test(navigator.userAgent)
? "⌘K"
@@ -82,7 +91,6 @@ export const SearchBar: React.FC<SearchBarProps> = (props) => {
const closeSearch = () => setOpen(false);
const clearSearch = () => {
props.onSelectSearchOption(undefined, { shouldExitSearchMode: true });
- setSearchResetKey((key) => key + 1);
setOpen(false);
};