Skip to content

armgit / ente

Public Imported from GitHub
0

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

feat(photos-web):ctrl+f-focuses-the-search-input

Aswin Asok027195c260a1
diff --git a/web/packages/new/photos/components/SearchBar.tsx b/web/packages/new/photos/components/SearchBar.tsx
index 2c97d044ec..a985044cd1 100644
--- a/web/packages/new/photos/components/SearchBar.tsx
+++ b/web/packages/new/photos/components/SearchBar.tsx
@@ -27,7 +27,7 @@ import type { SearchOption } from "ente-new/photos/services/search/types";
import { nullToUndefined } from "ente-utils/transform";
import { t } from "i18next";
import pDebounce from "p-debounce";
-import React, { useMemo, useRef, useState } from "react";
+import React, { useEffect, useMemo, useRef, useState } from "react";
import {
components as SelectComponents,
type ControlProps,
@@ -165,6 +165,20 @@ const SearchInput: React.FC<Omit<SearchBarProps, "onShowSearchInput">> = ({
const styles = useMemo(() => createSelectStyles(theme), [theme]);
const components = useMemo(() => ({ Control, Input, Option }), []);
+ // Handle ctrl+F keyboard shortcut to focus search
+ useEffect(() => {
+ const handleKeyDown = (event: KeyboardEvent) => {
+ // Check for ctrl+F (cmd+F on macOS)
+ if ((event.metaKey || event.ctrlKey) && event.key === "f") {
+ event.preventDefault();
+ selectRef.current?.focus();
+ }
+ };
+
+ document.addEventListener("keydown", handleKeyDown);
+ return () => document.removeEventListener("keydown", handleKeyDown);
+ }, []);
+
const handleChange = (value: SearchOption | null) => {
const type = value?.suggestion.type;
// Collection and people suggestions are handled differently - our