updateSearchKey(e.target.value)}
defaultValue={searchKey}
/>
diff --git a/themes/Hexo/components/SearchInput.js b/themes/Hexo/components/SearchInput.js
index d6ba0884..0912c374 100644
--- a/themes/Hexo/components/SearchInput.js
+++ b/themes/Hexo/components/SearchInput.js
@@ -35,17 +35,28 @@ const SearchInput = ({ currentTag, currentSearch, cRef }) => {
searchInputRef.current.value = ''
setSearchKey('')
}
-
+ let lock = false
const updateSearchKey = (val) => {
- setSearchKey(val)
+ if (!lock) {
+ setSearchKey(val)
+ }
+ }
+ function lockSearchInput () {
+ lock = true
}
+ function unLockSearchInput () {
+ lock = false
+ }
return
updateSearchKey(e.target.value)}
defaultValue={currentSearch}
/>
diff --git a/themes/Medium/components/SearchInput.js b/themes/Medium/components/SearchInput.js
index bd704624..baf6f859 100644
--- a/themes/Medium/components/SearchInput.js
+++ b/themes/Medium/components/SearchInput.js
@@ -37,8 +37,18 @@ const SearchInput = ({ currentTag, currentSearch, cRef, className }) => {
setSearchKey('')
}
+ let lock = false
const updateSearchKey = (val) => {
- setSearchKey(val)
+ if (!lock) {
+ setSearchKey(val)
+ }
+ }
+ function lockSearchInput () {
+ lock = true
+ }
+
+ function unLockSearchInput () {
+ lock = false
}
return
@@ -47,6 +57,9 @@ const SearchInput = ({ currentTag, currentSearch, cRef, className }) => {
type='text'
className={'w-full text-sm pl-2 transition focus:shadow-lg font-light leading-10 text-black bg-gray-100 dark:bg-gray-900 dark:text-white'}
onKeyUp={handleKeyUp}
+ onCompositionStart={lockSearchInput}
+ onCompositionUpdate={lockSearchInput}
+ onCompositionEnd={unLockSearchInput}
onChange={e => updateSearchKey(e.target.value)}
defaultValue={searchKey}
/>
diff --git a/themes/NEXT/components/SearchInput.js b/themes/NEXT/components/SearchInput.js
index 99e54ec1..153001e0 100644
--- a/themes/NEXT/components/SearchInput.js
+++ b/themes/NEXT/components/SearchInput.js
@@ -39,9 +39,19 @@ const SearchInput = ({ currentTag, currentSearch, cRef }) => {
searchInputRef.current.value = ''
setShowClean(false)
}
+ let lock = false
+ function lockSearchInput () {
+ lock = true
+ }
+ function unLockSearchInput () {
+ lock = false
+ }
const [showClean, setShowClean] = useState(false)
const updateSearchKey = (val) => {
+ if (lock) {
+ return
+ }
searchInputRef.current.value = val
if (val) {
setShowClean(true)
@@ -57,6 +67,9 @@ const SearchInput = ({ currentTag, currentSearch, cRef }) => {
placeholder={currentTag ? `${locale.SEARCH.TAGS} #${currentTag}` : `${locale.SEARCH.ARTICLES}`}
className={'w-full text-sm pl-4 transition focus:shadow-lg font-light leading-10 border-gray-300 text-black bg-gray-100 dark:bg-gray-900 dark:text-white'}
onKeyUp={handleKeyUp}
+ onCompositionStart={lockSearchInput}
+ onCompositionUpdate={lockSearchInput}
+ onCompositionEnd={unLockSearchInput}
onChange={e => updateSearchKey(e.target.value)}
defaultValue={currentSearch}
/>