Skip to content

Commit 4a7615c

Browse files
committed
Updated elementOverflow to account for horizontal overflows
1 parent a816479 commit 4a7615c

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎packages/react/src/util/elementOverflow.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,23 @@ export function elementOverflow(element: HTMLElement, container: HTMLElement) {
44

55
const topOverflow = elementRect.top < parentRect.top;
66
const bottomOverflow = elementRect.bottom > parentRect.bottom;
7+
const leftOverflow = elementRect.left < parentRect.left;
8+
const rightOverflow = elementRect.right > parentRect.right;
9+
10+
const horizontalOverflow =
11+
leftOverflow && rightOverflow
12+
? "both"
13+
: leftOverflow
14+
? "left"
15+
: rightOverflow
16+
? "right"
17+
: "none";
718

819
return topOverflow && bottomOverflow
920
? "both"
1021
: topOverflow
1122
? "top"
1223
: bottomOverflow
1324
? "bottom"
14-
: "none";
25+
: horizontalOverflow;
1526
}

0 commit comments

Comments
 (0)