From 97d585dc1735b5b0686cc7e3690949b43530c498 Mon Sep 17 00:00:00 2001 From: WalkxCode Date: Sat, 25 Jun 2022 14:02:53 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Adds=20query=20placeholder=20and=20?= =?UTF-8?q?autoFocus=20(#267=20#268)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Settings/CommonSettings.tsx | 11 ++++++++++- src/components/modules/search/SearchModule.tsx | 9 ++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/components/Settings/CommonSettings.tsx b/src/components/Settings/CommonSettings.tsx index 7b7665490..528983dae 100644 --- a/src/components/Settings/CommonSettings.tsx +++ b/src/components/Settings/CommonSettings.tsx @@ -28,6 +28,15 @@ export default function CommonSettings(args: any) { Search engine + + Tip: %s can be used as a placeholder for the query. + { setCustomSearchUrl(event.currentTarget.value); diff --git a/src/components/modules/search/SearchModule.tsx b/src/components/modules/search/SearchModule.tsx index 85ca6adf5..5848c4c87 100644 --- a/src/components/modules/search/SearchModule.tsx +++ b/src/components/modules/search/SearchModule.tsx @@ -96,7 +96,13 @@ export default function SearchBar(props: any) { } else if (isTorrent) { window.open(`https://bitsearch.to/search?q=${query.substring(3)}`); } else { - window.open(`${queryUrl}${values.query}`); + window.open( + `${ + queryUrl.includes('%s') + ? queryUrl.replace('%s', values.query) + : queryUrl + values.query + }` + ); } }, 20); })} @@ -114,6 +120,7 @@ export default function SearchBar(props: any) { onBlurCapture={() => setOpened(false)} target={