From 5661729748985d17edd7b73074131a2b9d3270d9 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Thu, 21 Sep 2023 22:31:12 +0800 Subject: [PATCH] Select input text whenever open global search command UI --- src/components/search-command.jsx | 1 + src/components/search-form.jsx | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/components/search-command.jsx b/src/components/search-command.jsx index 5b58efa7..105ab97e 100644 --- a/src/components/search-command.jsx +++ b/src/components/search-command.jsx @@ -16,6 +16,7 @@ export default memo(function SearchCommand({ onClose = () => {} }) { setShowSearch(true); setTimeout(() => { searchFormRef.current?.focus?.(); + searchFormRef.current?.select?.(); }, 0); }, { diff --git a/src/components/search-form.jsx b/src/components/search-form.jsx index 1f155540..579e5df9 100644 --- a/src/components/search-form.jsx +++ b/src/components/search-form.jsx @@ -23,6 +23,9 @@ const SearchForm = forwardRef((props, ref) => { focus: () => { searchFieldRef.current.focus(); }, + select: () => { + searchFieldRef.current.select(); + }, blur: () => { searchFieldRef.current.blur(); },