Skip to content

Commit d7f7b32

Browse files
johannes-weberJohannes Weber
andauthored
fix: Ensure portal ref exists and is in DOM before use in DragHandle arrow overlay (#3505)
Co-authored-by: Johannes Weber <jowejowe@amazon.com>
1 parent c9f14f6 commit d7f7b32

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/internal/components/drag-handle-wrapper/portal-overlay.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ export default function PortalOverlay({
3333
let lastInlineSize: number | undefined;
3434
let lastBlockSize: number | undefined;
3535
const updateElement = () => {
36-
if (ref.current) {
36+
// It could be that the portal hasn't been attached to the DOM yet - ensure the ref exists and is attached DOM tree.
37+
if (ref.current && document.body.contains(ref.current)) {
3738
const isRtl = getIsRtl(ref.current);
3839
const { insetInlineStart, insetBlockStart, inlineSize, blockSize } = getLogicalBoundingClientRect(track);
3940
// For simplicity, we just make all our calculations independent of

0 commit comments

Comments
 (0)