Skip to content

Commit 6490f58

Browse files
committed
Implement scrollable container detection for clipboard bounding rectangle
1 parent aea3f44 commit 6490f58

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

apps/roam/src/components/canvas/Clipboard.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,23 @@ const ClipboardPageSection = ({
770770
const zoomLevel = editor.getZoomLevel();
771771
const screenW = w * zoomLevel;
772772
const screenH = h * zoomLevel;
773-
const containerRect = containerRef.getBoundingClientRect();
773+
774+
let scrollableContainer: HTMLElement | null = containerRef;
775+
while (scrollableContainer) {
776+
const style = window.getComputedStyle(scrollableContainer);
777+
if (
778+
style.overflowY === "auto" ||
779+
style.overflowY === "scroll" ||
780+
style.overflow === "auto" ||
781+
style.overflow === "scroll"
782+
) {
783+
break;
784+
}
785+
scrollableContainer = scrollableContainer.parentElement;
786+
}
787+
788+
const checkContainer = scrollableContainer || containerRef;
789+
const containerRect = checkContainer.getBoundingClientRect();
774790
const box = new Box(
775791
containerRect.x,
776792
containerRect.y,

0 commit comments

Comments
 (0)