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.
9 lines
444 B
TypeScript
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;
|
|
}
|