Unverified Commit 65850dfd authored by Jason Chen's avatar Jason Chen Committed by GitHub

feat: auto focus search bar when sidebar is shown (close #1269) (#1304)

feat: auto focus search bar when sidebar is shown
parent d1bafd66
...@@ -32,6 +32,10 @@ export const toggleHomeSidebar = (show?: boolean) => { ...@@ -32,6 +32,10 @@ export const toggleHomeSidebar = (show?: boolean) => {
if (show) { if (show) {
sidebarEl.classList.add("show"); sidebarEl.classList.add("show");
maskEl.classList.add("show"); maskEl.classList.add("show");
// auto focus search bar when sidebar is shown
const inputEl = sidebarEl.querySelector("#mobile-search-bar") as HTMLInputElement;
inputEl?.focus();
} else { } else {
sidebarEl.classList.remove("show"); sidebarEl.classList.remove("show");
maskEl.classList.remove("show"); maskEl.classList.remove("show");
......
...@@ -54,6 +54,7 @@ const SearchBar = () => { ...@@ -54,6 +54,7 @@ const SearchBar = () => {
<input <input
className="flex ml-2 w-24 grow text-sm outline-none bg-transparent dark:text-gray-200" className="flex ml-2 w-24 grow text-sm outline-none bg-transparent dark:text-gray-200"
type="text" type="text"
id="mobile-search-bar"
placeholder="Search memos" placeholder="Search memos"
ref={inputRef} ref={inputRef}
value={queryText} value={queryText}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment