Make sure the tag’s condition menu is within the limits of <body>

Otherwise, when the tag input is too close to the right side of the
screen, it may be unreadable without scrolling.
This commit is contained in:
jordi fita mas 2023-04-17 11:51:10 +02:00
parent 149557e42e
commit 884c6dc2db
1 changed files with 13 additions and 0 deletions

View File

@ -428,6 +428,19 @@ class Tags extends HTMLDivElement {
} }
} }
conditions.remove(); 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;
}
});
} }
} }
} }