mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 23:29:02 +02:00
chore(react/note_icon): focus search by default
This commit is contained in:
parent
4d71b73f38
commit
076c0321cf
@ -2,7 +2,7 @@ import Dropdown from "./react/Dropdown";
|
|||||||
import "./note_icon.css";
|
import "./note_icon.css";
|
||||||
import { t } from "i18next";
|
import { t } from "i18next";
|
||||||
import { useNoteContext } from "./react/hooks";
|
import { useNoteContext } from "./react/hooks";
|
||||||
import { useCallback, useEffect, useState } from "preact/hooks";
|
import { useCallback, useEffect, useRef, useState } from "preact/hooks";
|
||||||
import server from "../services/server";
|
import server from "../services/server";
|
||||||
import type { Category, Icon } from "./icon_list";
|
import type { Category, Icon } from "./icon_list";
|
||||||
import FormTextBox from "./react/FormTextBox";
|
import FormTextBox from "./react/FormTextBox";
|
||||||
@ -50,6 +50,7 @@ export default function NoteIcon() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function NoteIconList() {
|
function NoteIconList() {
|
||||||
|
const searchBoxRef = useRef<HTMLInputElement>(null);
|
||||||
const [ search, setSearch ] = useState<string>();
|
const [ search, setSearch ] = useState<string>();
|
||||||
const [ categoryId, setCategoryId ] = useState<string>("0");
|
const [ categoryId, setCategoryId ] = useState<string>("0");
|
||||||
const [ iconData, setIconData ] = useState<IconData>();
|
const [ iconData, setIconData ] = useState<IconData>();
|
||||||
@ -101,6 +102,11 @@ function NoteIconList() {
|
|||||||
loadIcons();
|
loadIcons();
|
||||||
}, [ search, categoryId ]);
|
}, [ search, categoryId ]);
|
||||||
|
|
||||||
|
// Focus on search by default.
|
||||||
|
useEffect(() => {
|
||||||
|
searchBoxRef?.current?.focus();
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div class="filter-row">
|
<div class="filter-row">
|
||||||
@ -114,6 +120,7 @@ function NoteIconList() {
|
|||||||
|
|
||||||
<span>{t("note_icon.search")}</span>
|
<span>{t("note_icon.search")}</span>
|
||||||
<FormTextBox
|
<FormTextBox
|
||||||
|
inputRef={searchBoxRef}
|
||||||
type="text"
|
type="text"
|
||||||
name="icon-search"
|
name="icon-search"
|
||||||
currentValue={search} onChange={setSearch}
|
currentValue={search} onChange={setSearch}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user