From 884c6dc2dba0973f48f90465329f3a2249fb3945 Mon Sep 17 00:00:00 2001 From: jordi fita mas Date: Mon, 17 Apr 2023 11:51:10 +0200 Subject: [PATCH] =?UTF-8?q?Make=20sure=20the=20tag=E2=80=99s=20condition?= =?UTF-8?q?=20menu=20is=20within=20the=20limits=20of=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise, when the tag input is too close to the right side of the screen, it may be unreadable without scrolling. --- web/static/numerus.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/web/static/numerus.js b/web/static/numerus.js index 1c7e3e2..e3cb1d9 100644 --- a/web/static/numerus.js +++ b/web/static/numerus.js @@ -428,6 +428,19 @@ class Tags extends HTMLDivElement { } } conditions.remove(); + + details.addEventListener('toggle', function (e) { + const menu = e.target.querySelector('[role="menu"]'); + if (e.target.open) { + const rect = menu.getBoundingClientRect(); + if (rect.right > document.body.clientWidth) { + menu.style.left = Math.ceil(document.body.clientWidth - rect.right) + 'px'; + } + console.log(rect, document.body.clientWidth); + } else { + menu.style.left = 0; + } + }); } } }