Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix(searchbar):fixed-menu-showing-up

Aswin Asok5254d03ec6a5
diff --git a/web/packages/new/photos/components/SearchBar.tsx b/web/packages/new/photos/components/SearchBar.tsx
index 66b433fadd..68dfbba4e2 100644
--- a/web/packages/new/photos/components/SearchBar.tsx
+++ b/web/packages/new/photos/components/SearchBar.tsx
@@ -164,6 +164,7 @@ const SearchInput: React.FC<Omit<SearchBarProps, "onShowSearchInput">> = ({
const [value, setValue] = useState<SearchOption | null>(null);
// The contents of the input field associated with the select.
const [inputValue, setInputValue] = useState("");
+ const [isFocused, setIsFocused] = useState(false);
const theme = useTheme();
@@ -254,6 +255,7 @@ const SearchInput: React.FC<Omit<SearchBarProps, "onShowSearchInput">> = ({
};
const handleFocus = () => {
+ setIsFocused(true);
// A workaround to show the suggestions again for the current non-empty
// search string if the user focuses back on the input field after
// moving focus elsewhere.
@@ -265,6 +267,10 @@ const SearchInput: React.FC<Omit<SearchBarProps, "onShowSearchInput">> = ({
}
};
+ const handleBlur = () => {
+ setIsFocused(false);
+ };
+
return (
<SearchInputWrapper>
<AsyncSelect
@@ -278,7 +284,9 @@ const SearchInput: React.FC<Omit<SearchBarProps, "onShowSearchInput">> = ({
onInputChange={handleInputChange}
isClearable
escapeClearsValue
+ menuIsOpen={isFocused && inputValue !== ""}
onFocus={handleFocus}
+ onBlur={handleBlur}
placeholder={t("search_hint")}
noOptionsMessage={({ inputValue }) =>
shouldShowEmptyState(inputValue) ? (