Skip to content

Commit 13be280

Browse files
authored
🐛 fix(ui): 使用 autoFocus 避免 .focus() 对动态生成的 input 呼叫失败 (#1019)
1 parent 79505ef commit 13be280

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/pages/options/routes/script/ScriptEditor.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -889,12 +889,6 @@ function ScriptEditor() {
889889
}}
890890
onClick={() => {
891891
setShowSearchInput(!showSearchInput);
892-
setTimeout(
893-
() =>
894-
showSearchInput &&
895-
(document.querySelector("#editor_search_scripts_input") as HTMLInputElement)?.focus(),
896-
1
897-
);
898892
}}
899893
>
900894
<div className="flex justify-between items-center">
@@ -911,7 +905,8 @@ function ScriptEditor() {
911905
<Input
912906
placeholder={t("search_scripts")}
913907
allowClear
914-
value={searchKeyword}
908+
autoFocus
909+
defaultValue={searchKeyword}
915910
onChange={(value) => setSearchKeyword(value)}
916911
size="mini"
917912
id="editor_search_scripts_input"

0 commit comments

Comments
 (0)