Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix(photos):keep-search-results-visible-on-blur

Aswin Asok077927ca609a
diff --git a/web/apps/photos/src/components/SearchBar.tsx b/web/apps/photos/src/components/SearchBar.tsx
index 2cd1f0baa9..cf76d9983e 100644
--- a/web/apps/photos/src/components/SearchBar.tsx
+++ b/web/apps/photos/src/components/SearchBar.tsx
@@ -102,7 +102,7 @@ export const SearchBar: React.FC<SearchBarProps> = (props) => {
</EnteLogoBox>
)}
</Box>
- <Tooltip title={t("search_shortcut", { shortcut })}>
+ <Tooltip title={`Search (${shortcut})`}>
<FocusVisibleButton
color="secondary"
aria-label={t("search")}
@@ -173,7 +173,6 @@ const SearchInput: React.FC<
// undefined makes react-select switch from controlled to uncontrolled.
const [value, setValue] = useState<SearchOption | null>(null);
const [inputValue, setInputValue] = useState("");
- const [isFocused, setIsFocused] = useState(false);
const [isKeyboardNavigating, setIsKeyboardNavigating] = useState(false);
const theme = useTheme();
@@ -215,6 +214,13 @@ const SearchInput: React.FC<
};
const handleInputChange = (value: string, actionMeta: InputActionMeta) => {
+ // AsyncSelect otherwise clears loaded options when the input blurs.
+ if (
+ actionMeta.action === "input-blur" ||
+ actionMeta.action === "menu-close"
+ ) {
+ return inputValue;
+ }
if (actionMeta.action == "input-change") {
setIsKeyboardNavigating(false);
setInputValue(value);
@@ -227,6 +233,7 @@ const SearchInput: React.FC<
});
}
}
+ return value;
};
const resetSearch = () => {
@@ -250,7 +257,6 @@ const SearchInput: React.FC<
};
const handleFocus = () => {
- setIsFocused(true);
// Refocusing needs an input nudge to reopen unchanged suggestions.
if (inputValue) {
selectRef.current?.onInputChange(inputValue, {
@@ -261,7 +267,6 @@ const SearchInput: React.FC<
};
const handleBlur = () => {
- setIsFocused(false);
setIsKeyboardNavigating(false);
};
@@ -291,7 +296,7 @@ const SearchInput: React.FC<
aria-label={t("search")}
escapeClearsValue
menuIsOpen={
- isFocused && (inputValue !== "" || shouldShowEmptyState(""))
+ open && (inputValue !== "" || shouldShowEmptyState(""))
}
onFocus={handleFocus}
onBlur={handleBlur}
diff --git a/web/packages/base/locales/en-US/translation.json b/web/packages/base/locales/en-US/translation.json
index d3f65d11b6..596ef01b3c 100644
--- a/web/packages/base/locales/en-US/translation.json
+++ b/web/packages/base/locales/en-US/translation.json
@@ -471,7 +471,6 @@
"link_edit_disabled_for_free_accounts": "You need a paid subscription to change this link setting",
"sharing_user_does_not_exist": "Could not find a user with that email",
"search": "Search",
- "search_shortcut": "Search ({{shortcut}})",
"people_search_hint": "Search people",
"search_results": "Search results",
"no_results": "No results found",