From 456406224eb8bb5653478f7233dce151dcfadb1f Mon Sep 17 00:00:00 2001 From: Web-serfer Date: Sun, 3 May 2026 23:55:44 +0500 Subject: [PATCH] =?UTF-8?q?fix:=20=D0=B0=D0=B4=D0=B0=D0=BF=D1=82=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=B4=20=D0=B2=D0=B8=D1=80=D1=82=D1=83=D0=B0=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D1=83=D1=8E=20=D0=BA=D0=BB=D0=B0=D0=B2=D0=B8=D0=B0?= =?UTF-8?q?=D1=82=D1=83=D1=80=D1=83=20=D0=BD=D0=B0=20=D0=BC=D0=BE=D0=B1?= =?UTF-8?q?=D0=B8=D0=BB=D1=8C=D0=BD=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/base/SearchModal.astro | 54 ++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/base/SearchModal.astro b/frontend/src/components/base/SearchModal.astro index 8092e90..f174cd1 100644 --- a/frontend/src/components/base/SearchModal.astro +++ b/frontend/src/components/base/SearchModal.astro @@ -67,11 +67,42 @@ const title = 'Поиск по статьям'; return d.toLocaleDateString('ru-RU', { day: 'numeric', month: 'long', year: 'numeric' }); } + function updateResultsHeight() { + const viewport = window.visualViewport; + let availableHeight; + + if (viewport) { + availableHeight = viewport.height; + } else { + availableHeight = window.innerHeight; + } + + const modalContainer = modal.querySelector('.modal-container'); + if (!modalContainer) return; + + const modalRect = modalContainer.getBoundingClientRect(); + const headerHeight = modalRect.top + 80; + const inputHeight = 60; + const padding = 40; + + const resultsMaxHeight = availableHeight - headerHeight - inputHeight - padding; + resultsContainer.style.maxHeight = `${Math.max(200, resultsMaxHeight)}px`; + } + function openModal() { modal.classList.add('active'); modal.setAttribute('aria-hidden', 'false'); document.body.style.overflow = 'hidden'; - setTimeout(() => searchInput.focus(), 200); + setTimeout(() => { + searchInput.focus(); + updateResultsHeight(); + }, 200); + + if (window.visualViewport) { + window.visualViewport.addEventListener('resize', updateResultsHeight); + } else { + window.addEventListener('resize', updateResultsHeight); + } } function closeModal() { @@ -80,6 +111,13 @@ const title = 'Поиск по статьям'; document.body.style.overflow = ''; searchInput.value = ''; resultsContainer.innerHTML = ''; + resultsContainer.style.maxHeight = ''; + + if (window.visualViewport) { + window.visualViewport.removeEventListener('resize', updateResultsHeight); + } else { + window.removeEventListener('resize', updateResultsHeight); + } } async function handleSearch(query) { @@ -253,6 +291,20 @@ const title = 'Поиск по статьям'; display: flex; flex-direction: column; gap: 16px; + max-height: 400px; + transition: max-height 0.3s ease; + } + + @media (max-width: 640px) { + .search-results { + max-height: 300px; + } + } + + @media (max-height: 500px) { + .search-results { + max-height: 200px; + } } .search-result-item {