fix: keep session filter menus open while scrolling (#140)

This commit is contained in:
Leon Zhao
2026-09-28 16:56:10 +08:00
committed by GitHub
parent acd00dc4fb
commit 82b0239dd0
2 changed files with 6 additions and 4 deletions
+1 -1
View File
@@ -482,7 +482,7 @@ body.window .field.solo { grid-column: auto; }
.sess-pick:hover { background: var(--pill); }
.sess-pick.set { color: var(--fg); border-color: var(--line-2); background: var(--pill); }
.sess-pick.open svg { transform: rotate(180deg); }
.pop.proto-menu.sess-menu { width: 300px; max-height: min(360px, 70vh); overflow-y: auto; }
.pop.proto-menu.sess-menu { width: 300px; max-height: min(360px, 70vh); overflow-y: auto; overscroll-behavior: contain; }
.sess-menu .pm-name, .sess-menu .pm-note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sess-chart-head { display: flex; align-items: center; gap: 8px; margin: -2px 0 8px; }
.sess-chart-head .label { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
+5 -3
View File
@@ -3832,7 +3832,7 @@ function closeProtoMenu() {
protoMenu.box.remove();
document.removeEventListener("mousedown", protoMenu.outside, true);
document.removeEventListener("keydown", protoMenu.keys, true);
document.removeEventListener("scroll", closeProtoMenu, true);
document.removeEventListener("scroll", protoMenu.scroll, true);
removeEventListener("resize", closeProtoMenu);
protoMenu = null;
}
@@ -3865,6 +3865,8 @@ function openProtoMenu(anchor, opts, value, choose, head = "Protocol this key sp
box.style.top = Math.max(pad, y) + "px";
anchor.classList.add("open");
const outside = (e) => { if (!box.contains(e.target) && !anchor.contains(e.target)) closeProtoMenu(); };
// Scrolling the menu keeps it open; scrolling outside moves its anchor.
const scroll = (e) => { if (!box.contains(e.target)) closeProtoMenu(); };
const keys = (e) => {
const i = items.indexOf(document.activeElement);
if (e.key === "Escape") { e.preventDefault(); e.stopPropagation(); closeProtoMenu(); anchor.focus(); }
@@ -3876,9 +3878,9 @@ function openProtoMenu(anchor, opts, value, choose, head = "Protocol this key sp
};
document.addEventListener("mousedown", outside, true);
document.addEventListener("keydown", keys, true);
document.addEventListener("scroll", closeProtoMenu, true); // it is pinned to the window; the dialog moving under it would strand it
document.addEventListener("scroll", scroll, true);
addEventListener("resize", closeProtoMenu);
protoMenu = { box, anchor, outside, keys };
protoMenu = { box, anchor, outside, keys, scroll };
(items.find((b) => b.classList.contains("on")) || items[0]).focus({ preventScroll: true });
}