From 9dc390586d02af50b433cf0abc8eca1beb445725 Mon Sep 17 00:00:00 2001 From: 0x4c2 <0x004c2@gmail.com> Date: Mon, 23 Oct 2023 22:49:09 +0800 Subject: [PATCH] Fix cursor visibility issue in mobile mode (#1087) * Resolve new cursor missing issue caused by previous 'Fix cursor missing issue' PR * Fix cursor visibility issue in mobile mode --- assets/js/theme.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/assets/js/theme.js b/assets/js/theme.js index 51d359176..ff5deb477 100644 --- a/assets/js/theme.js +++ b/assets/js/theme.js @@ -189,7 +189,10 @@ function initSearch () { window._searchMobileOnce = true // Turn on the mask when clicking on the search button searchInput.addEventListener('focus', () => { - loadScript('autocomplete-script', '/lib/autocomplete/autocomplete.min.js', () => initAutosearch()) + loadScript('autocomplete-script', '/lib/autocomplete/autocomplete.min.js', () => { + initAutosearch(); + searchInput.focus(); + }) if (window.config?.search?.type === 'algolia') { loadScript('algolia-script', '/lib/algoliasearch/algoliasearch-lite.umd.min.js', null) } else { @@ -197,6 +200,7 @@ function initSearch () { } document.body.classList.add('blur') header.classList.add('open') + searchInput.focus() }) // Turn off the everything when clicking on the cancel button document.getElementById('search-cancel-mobile').addEventListener('click', () => { @@ -236,6 +240,7 @@ function initSearch () { } document.body.classList.add('blur') header.classList.add('open') + searchInput.focus() }) // Clear the search box when clicking on the clear button searchClear.addEventListener('click', () => {