Try focus on search input again

This commit is contained in:
Lim Chee Aun 2024-11-19 20:21:41 +08:00
parent 6ebf5bd1c9
commit 2930d9c40b
2 changed files with 25 additions and 21 deletions

40
src/locales/en.po generated
View file

@ -97,8 +97,8 @@ msgstr "Following"
#: src/components/account-info.jsx:421 #: src/components/account-info.jsx:421
#: src/components/account-info.jsx:778 #: src/components/account-info.jsx:778
#: src/pages/account-statuses.jsx:484 #: src/pages/account-statuses.jsx:484
#: src/pages/search.jsx:323 #: src/pages/search.jsx:327
#: src/pages/search.jsx:470 #: src/pages/search.jsx:474
msgid "Posts" msgid "Posts"
msgstr "" msgstr ""
@ -956,8 +956,8 @@ msgstr ""
#: src/components/generic-accounts.jsx:145 #: src/components/generic-accounts.jsx:145
#: src/components/notification.jsx:438 #: src/components/notification.jsx:438
#: src/pages/accounts.jsx:41 #: src/pages/accounts.jsx:41
#: src/pages/search.jsx:313 #: src/pages/search.jsx:317
#: src/pages/search.jsx:346 #: src/pages/search.jsx:350
msgid "Accounts" msgid "Accounts"
msgstr "" msgstr ""
@ -965,14 +965,14 @@ msgstr ""
#: src/components/timeline.jsx:519 #: src/components/timeline.jsx:519
#: src/pages/list.jsx:293 #: src/pages/list.jsx:293
#: src/pages/notifications.jsx:848 #: src/pages/notifications.jsx:848
#: src/pages/search.jsx:540 #: src/pages/search.jsx:544
#: src/pages/status.jsx:1332 #: src/pages/status.jsx:1332
msgid "Show more…" msgid "Show more…"
msgstr "" msgstr ""
#: src/components/generic-accounts.jsx:210 #: src/components/generic-accounts.jsx:210
#: src/components/timeline.jsx:524 #: src/components/timeline.jsx:524
#: src/pages/search.jsx:545 #: src/pages/search.jsx:549
msgid "The end." msgid "The end."
msgstr "" msgstr ""
@ -1079,7 +1079,7 @@ msgstr ""
#: src/components/shortcuts-settings.jsx:52 #: src/components/shortcuts-settings.jsx:52
#: src/components/shortcuts-settings.jsx:179 #: src/components/shortcuts-settings.jsx:179
#: src/pages/search.jsx:45 #: src/pages/search.jsx:45
#: src/pages/search.jsx:295 #: src/pages/search.jsx:299
msgid "Search" msgid "Search"
msgstr "" msgstr ""
@ -2697,7 +2697,7 @@ msgstr ""
#: src/pages/catchup.jsx:1316 #: src/pages/catchup.jsx:1316
#: src/pages/mentions.jsx:147 #: src/pages/mentions.jsx:147
#: src/pages/search.jsx:308 #: src/pages/search.jsx:312
msgid "All" msgid "All"
msgstr "" msgstr ""
@ -3301,42 +3301,42 @@ msgstr ""
msgid "Search: {q}" msgid "Search: {q}"
msgstr "" msgstr ""
#: src/pages/search.jsx:318 #: src/pages/search.jsx:322
#: src/pages/search.jsx:400 #: src/pages/search.jsx:404
msgid "Hashtags" msgid "Hashtags"
msgstr "" msgstr ""
#: src/pages/search.jsx:350 #: src/pages/search.jsx:354
#: src/pages/search.jsx:404 #: src/pages/search.jsx:408
#: src/pages/search.jsx:474 #: src/pages/search.jsx:478
msgid "See more" msgid "See more"
msgstr "" msgstr ""
#: src/pages/search.jsx:376 #: src/pages/search.jsx:380
msgid "See more accounts" msgid "See more accounts"
msgstr "" msgstr ""
#: src/pages/search.jsx:390 #: src/pages/search.jsx:394
msgid "No accounts found." msgid "No accounts found."
msgstr "" msgstr ""
#: src/pages/search.jsx:446 #: src/pages/search.jsx:450
msgid "See more hashtags" msgid "See more hashtags"
msgstr "" msgstr ""
#: src/pages/search.jsx:460 #: src/pages/search.jsx:464
msgid "No hashtags found." msgid "No hashtags found."
msgstr "" msgstr ""
#: src/pages/search.jsx:504 #: src/pages/search.jsx:508
msgid "See more posts" msgid "See more posts"
msgstr "" msgstr ""
#: src/pages/search.jsx:518 #: src/pages/search.jsx:522
msgid "No posts found." msgid "No posts found."
msgstr "" msgstr ""
#: src/pages/search.jsx:562 #: src/pages/search.jsx:566
msgid "Enter your search term or paste a URL above to get started." msgid "Enter your search term or paste a URL above to get started."
msgstr "" msgstr ""

View file

@ -184,12 +184,16 @@ function Search({ columnMode, ...props }) {
}); });
useEffect(() => { useEffect(() => {
let timer;
searchFormRef.current?.setValue?.(q || ''); searchFormRef.current?.setValue?.(q || '');
if (q) { if (q) {
loadResults(true); loadResults(true);
} else { } else {
timer = setTimeout(() => {
searchFormRef.current?.focus?.(); searchFormRef.current?.focus?.();
}, 150); // Right after focusDeck runs
} }
return () => clearTimeout(timer);
}, [q, type, instance]); }, [q, type, instance]);
useHotkeys( useHotkeys(