Skip to content

Commit

Permalink
Improvements to table column cog menu display, closes #2263
Browse files Browse the repository at this point in the history
- Repositions if menu would cause a horizontal scrollbar
- Arrow tip on menu now attempts to align with cog icon on column
  • Loading branch information
simonw committed Feb 19, 2024
1 parent b36a2d8 commit 392ca2e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions datasette/static/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 392ca2e

Please sign in to comment.