Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/frontend/packages/shared/src/dropdown/edge.ts
iris 608eb9dcd9 shared: a dropdown that would run past the window's right edge hangs from the right of its trigger
The state menu on an agent card that fills the width hung from the
trigger's left edge, so the window cut the list off. The list now measures
itself when it opens and flips to the trigger's right edge when it would
overflow.
2026-11-27 17:10:27 +01:00

9 lines
444 B
TypeScript

// Where an option list opens, from the box it would take if it hung from the
// left of its trigger. Kept apart from the component so a test reaches it
// without a DOM.
/** Whether a list whose left-hung box ends at `right` needs to hang from the
* right of its trigger instead, to stay inside a window `viewportWidth` wide. */
export function hangsFromEnd(right: number, viewportWidth: number): boolean {
return right > viewportWidth;
}