Skip to content

Commit 63eaa79

Browse files
authored
fix(web): context menus no longer scroll when they fit the window (pingdotgg#16776)
1 parent 6a99eb3 commit 63eaa79

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎apps/web/src/contextMenuFallback.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,12 @@ export function showContextMenuFallback<T extends string>(
303303
menu.dataset.level = String(level);
304304

305305
const inner = document.createElement("div");
306+
// Fit the viewport (minus clampMenuPosition's 4px margins) so menus only
307+
// scroll when the window is shorter than the menu itself.
306308
inner.className =
307-
"max-h-[min(24rem,70vh)] min-w-0 max-w-sm overflow-y-auto overflow-x-hidden p-1";
309+
"max-h-[calc(100vh-0.5rem)] min-w-0 max-w-sm overflow-y-auto overflow-x-hidden p-1";
308310
inner.style.cssText =
309-
"max-height:min(24rem,70vh);min-width:0;max-width:24rem;overflow-x:hidden;overflow-y:auto;padding:0.25rem;";
311+
"max-height:calc(100vh - 0.5rem);min-width:0;max-width:24rem;overflow-x:hidden;overflow-y:auto;padding:0.25rem;";
310312

311313
for (const item of entries) {
312314
if (item.separatorBefore === true && inner.children.length > 0) {

0 commit comments

Comments
 (0)