diff --git a/apps/client/src/widgets/note_icon.tsx b/apps/client/src/widgets/note_icon.tsx
index 751036b57..dc133be47 100644
--- a/apps/client/src/widgets/note_icon.tsx
+++ b/apps/client/src/widgets/note_icon.tsx
@@ -102,11 +102,6 @@ function NoteIconList() {
loadIcons();
}, [ search, categoryId ]);
- // Focus on search by default.
- useEffect(() => {
- searchBoxRef?.current?.focus();
- }, []);
-
return (
<>
@@ -124,6 +119,7 @@ function NoteIconList() {
type="text"
name="icon-search"
currentValue={search} onChange={setSearch}
+ autoFocus
/>
diff --git a/apps/client/src/widgets/react/FormTextBox.tsx b/apps/client/src/widgets/react/FormTextBox.tsx
index 6fde90f62..db67bf6c9 100644
--- a/apps/client/src/widgets/react/FormTextBox.tsx
+++ b/apps/client/src/widgets/react/FormTextBox.tsx
@@ -1,4 +1,4 @@
-import type { InputHTMLAttributes, RefObject } from "preact/compat";
+import { useEffect, type InputHTMLAttributes, type RefObject } from "preact/compat";
interface FormTextBoxProps extends Omit, "onChange" | "onBlur" | "value"> {
id?: string;
@@ -8,7 +8,7 @@ interface FormTextBoxProps extends Omit, "
inputRef?: RefObject;
}
-export default function FormTextBox({ inputRef, className, type, currentValue, onChange, onBlur,...rest}: FormTextBoxProps) {
+export default function FormTextBox({ inputRef, className, type, currentValue, onChange, onBlur, autoFocus, ...rest}: FormTextBoxProps) {
if (type === "number" && currentValue) {
const { min, max } = rest;
const currentValueNum = parseInt(currentValue, 10);
@@ -19,6 +19,12 @@ export default function FormTextBox({ inputRef, className, type, currentValue, o
}
}
+ useEffect(() => {
+ if (autoFocus) {
+ inputRef?.current?.focus();
+ }
+ }, []);
+
return (