Skip to content

Commit 43461aa

Browse files
committed
🐛 fix(ui): 使用 autoFocus 避免 .focus() 对动态生成的 input 呼叫失败 (#1019)
1 parent d1a5cb1 commit 43461aa

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -897,12 +897,6 @@ function ScriptEditor() {
897897
}}
898898
onClick={() => {
899899
setShowSearchInput(!showSearchInput);
900-
setTimeout(
901-
() =>
902-
showSearchInput &&
903-
(document.querySelector("#editor_search_scripts_input") as HTMLInputElement)?.focus(),
904-
1
905-
);
906900
}}
907901
>
908902
<div className="tw-flex tw-justify-between tw-items-center">
@@ -919,7 +913,8 @@ function ScriptEditor() {
919913
<Input
920914
placeholder={t("search_scripts")}
921915
allowClear
922-
value={searchKeyword}
916+
autoFocus
917+
defaultValue={searchKeyword}
923918
onChange={(value) => setSearchKeyword(value)}
924919
size="mini"
925920
id="editor_search_scripts_input"

0 commit comments

Comments
 (0)