fix: keep list menus on screen and clip long activity subtitles

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-17 13:26:11 +03:30
co-authored by Cursor
parent 2c7c943802
commit 177e5cc31b
5 changed files with 158 additions and 101 deletions
+18 -4
View File
@@ -7,19 +7,33 @@ export function cardMenuStyle(
const buttons = Array.from(
document.querySelectorAll<HTMLElement>(`[data-card-id="${CSS.escape(cardId)}"] .menu`),
);
// در نمای لیست هم جدول و هم کارت در DOM هستند؛ دکمهٔ واقعاً دیده را بگیر
const btn =
buttons.find((el) => {
const r = el.getBoundingClientRect();
return r.width > 0 && r.height > 0;
}) ?? buttons[0];
if (r.width < 1 || r.height < 1) return false;
let node: HTMLElement | null = el;
while (node) {
const style = getComputedStyle(node);
if (style.display === 'none' || style.visibility === 'hidden') return false;
node = node.parentElement;
}
return true;
}) ?? null;
if (!btn) return null;
const r = btn.getBoundingClientRect();
const gap = 4;
const left = Math.min(Math.max(8, r.left), window.innerWidth - width - 8);
const fitsBelow = r.bottom + gap + height <= window.innerHeight;
const top = fitsBelow ? r.bottom + gap : Math.max(8, r.top - height - gap);
return { inset: 'auto', top: `${top}px`, left: `${left}px`, minWidth: `${width}px` };
// inset را ست نکن؛ shorthand مقدار top/left را خنثی می‌کند
return {
position: 'fixed',
top: `${top}px`,
left: `${left}px`,
right: 'auto',
bottom: 'auto',
minWidth: `${width}px`,
};
}
/** بستن منو با کلیک بیرون، Escape یا اسکرول */