Improvements to table column cog menu display, closes #2263

- Repositions if menu would cause a horizontal scrollbar
- Arrow tip on menu now attempts to align with cog icon on column
pull/2004/merge
Simon Willison 2024-02-19 13:40:48 -08:00
rodzic b36a2d8f4b
commit 392ca2e24c
1 zmienionych plików z 11 dodań i 0 usunięć

Wyświetl plik

@ -217,6 +217,17 @@ const initDatasetteTable = function (manager) {
menuList.appendChild(menuItem);
});
// Measure width of menu and adjust position if too far right
const menuWidth = menu.offsetWidth;
const windowWidth = window.innerWidth;
if (menuLeft + menuWidth > windowWidth) {
menu.style.left = windowWidth - menuWidth - 20 + "px";
}
// Align menu .hook arrow with the column cog icon
const hook = menu.querySelector('.hook');
const icon = th.querySelector('.dropdown-menu-icon');
const iconRect = icon.getBoundingClientRect();
hook.style.left = (iconRect.left - menuLeft + 1) + 'px';
}
var svg = document.createElement("div");