From 70bf6eeb56a979fbe9ef6f7ec3cb743b6d664806 Mon Sep 17 00:00:00 2001 From: vitya-ne <9317613+vitya-ne@users.noreply.github.com> Date: Fri, 30 Aug 2024 21:54:30 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D1=82=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D1=83=20=D0=BF=D0=B5=D1=80=D0=B5=D1=85=D0=BE=D0=B4=D0=B0?= =?UTF-8?q?=20=D0=BA=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=D1=83=20=D0=BF=D0=BE?= =?UTF-8?q?=20=D0=BA=D0=BB=D0=B0=D0=B2=D0=B8=D1=88=D0=B5=20'/'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scripts/modules/header.js | 7 +++++++ src/scripts/modules/search.js | 11 +++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/scripts/modules/header.js b/src/scripts/modules/header.js index c0b98afe..601b6f46 100644 --- a/src/scripts/modules/header.js +++ b/src/scripts/modules/header.js @@ -88,6 +88,13 @@ class Header extends BaseComponent { this.checkSticky() } + document.addEventListener('keydown', (event) => { + // Firefox при нажатии Slash открывает свой поиск по странице + if (document.activeElement !== this.refs.input && (event.code === 'Slash' || event.code === 'NumpadDivide')) { + event.preventDefault() + } + }) + if (this.isMainPage) { document.addEventListener('keyup', (event) => { if (event.code === 'Slash' || event.code === 'NumpadDivide') { diff --git a/src/scripts/modules/search.js b/src/scripts/modules/search.js index c0bf355a..5999c27e 100644 --- a/src/scripts/modules/search.js +++ b/src/scripts/modules/search.js @@ -276,14 +276,13 @@ function init() { event.preventDefault() }) - document.addEventListener('keydown', (event) => { - // Блокировка показа встроенного поиска в Firefox - if ((event.code === 'Slash' || event.code === 'NumpadDivide') && document.activeElement !== searchField) { - event.preventDefault() + document.addEventListener('keyup', (event) => { + if (event.code === 'Slash' && document.activeElement !== searchField) { + queueMicrotask(() => { + searchField.focus() + }) } - }) - document.addEventListener('keyup', (event) => { if (event.code === 'Enter' && document.activeElement === searchField) { queueMicrotask(() => { document.querySelector(SEARCH_HIT_LINK_SELECTOR)?.focus()