dropdown out of screen fix

This commit is contained in:
Yuri Kuznetsov
2025-04-19 19:29:12 +03:00
parent e1acf4a2b8
commit 90bcd57d2c
2 changed files with 36 additions and 0 deletions

View File

@@ -58,10 +58,15 @@ function uiAppInit() {
$document.on('show.bs.dropdown', e => {
let isUp;
/** @type {HTMLElement} */
const target = e.target;
const $dropdown = $(e.target).find('.dropdown-menu');
/** @type {HTMLElement} */
const dropdownElement = $dropdown.get(0);
const height = $dropdown.outerHeight();
const width = $dropdown.outerWidth();
{
const $target = $(target);
@@ -84,6 +89,20 @@ function uiAppInit() {
}
}
if (target.getBoundingClientRect().left - width < 0) {
const maxWidth = target.getBoundingClientRect().right - target.getBoundingClientRect().width / 2;
dropdownElement.style.maxWidth = maxWidth + 'px';
const $group = $(target);
$group.one('hidden.bs.dropdown', () => {
dropdownElement.style.maxWidth = '';
});
return;
}
const $dashletBody = $(target).closest('.dashlet-body');
if ($dashletBody.length) {

View File

@@ -201,6 +201,23 @@ ul.dropdown-menu {
}
}
@media screen and (max-width: @screen-xs-max) {
ul.dropdown-menu {
max-width: 100vw;
> li {
> a {
&,
> div {
overflow: hidden;
text-overflow: ellipsis;
}
}
}
}
}
ul.dropdown-menu {
> li.divider:first-child {
display: none;