다른 명령
(새 문서: →이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다.: →* * Autofocus search input on mobile * Triggered when MobileFrontend search UI opens * Improves UX by immediately opening the virtual keyboard: mw.hook('mobileFrontend.search.open').add(function () { setTimeout(function () { const input = document.querySelector('.citizen-search__input') || document.querySelector('#searchInput') ||...) |
편집 요약 없음 |
||
| 7번째 줄: | 7번째 줄: | ||
*/ | */ | ||
mw.hook('mobileFrontend.search.open').add(function () { | mw.hook('mobileFrontend.search.open').add(function () { | ||
const tryFocus = () => { | |||
const input = | const input = | ||
document.querySelector('.citizen-search__input') || | document.querySelector('.citizen-search__input') || | ||
| 14번째 줄: | 14번째 줄: | ||
if (input) { | if (input) { | ||
input.focus(); | input.focus({ preventScroll: true }); | ||
input.click(); // 모바일에서 키보드 트리거에 도움 될 때가 있음 | |||
} | } | ||
} | }; | ||
requestAnimationFrame(() => requestAnimationFrame(tryFocus)); | |||
}); | }); | ||
2026년 1월 17일 (토) 18:33 판
/* 이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다. */
/**
* Autofocus search input on mobile
* Triggered when MobileFrontend search UI opens
* Improves UX by immediately opening the virtual keyboard
*/
mw.hook('mobileFrontend.search.open').add(function () {
const tryFocus = () => {
const input =
document.querySelector('.citizen-search__input') ||
document.querySelector('#searchInput') ||
document.querySelector('input[type="search"]');
if (input) {
input.focus({ preventScroll: true });
input.click(); // 모바일에서 키보드 트리거에 도움 될 때가 있음
}
};
requestAnimationFrame(() => requestAnimationFrame(tryFocus));
});