From da888eea8675ff07ad3b2b8f43bc52408b69bd66 Mon Sep 17 00:00:00 2001 From: Will Donohoe Date: Sat, 18 Feb 2023 18:38:31 -0800 Subject: [PATCH] Fix errors in firefox extension when destructuring the window (#1038) --- .changeset/firefox-getcomputedstyle-fix.md | 5 +++++ packages/core/src/utilities/rect/getRect.ts | 4 ++-- packages/core/src/utilities/scroll/getScrollableAncestors.ts | 3 +-- 3 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 .changeset/firefox-getcomputedstyle-fix.md diff --git a/.changeset/firefox-getcomputedstyle-fix.md b/.changeset/firefox-getcomputedstyle-fix.md new file mode 100644 index 00000000..1ae45003 --- /dev/null +++ b/.changeset/firefox-getcomputedstyle-fix.md @@ -0,0 +1,5 @@ +--- +"@dnd-kit/core": patch +--- + +Fix errors with calls to `getComputedStyle` in Firefox when destructuring from the window object diff --git a/packages/core/src/utilities/rect/getRect.ts b/packages/core/src/utilities/rect/getRect.ts index 05de9bb6..8797828f 100644 --- a/packages/core/src/utilities/rect/getRect.ts +++ b/packages/core/src/utilities/rect/getRect.ts @@ -19,8 +19,8 @@ export function getClientRect( let rect: ClientRect = element.getBoundingClientRect(); if (options.ignoreTransform) { - const {getComputedStyle} = getWindow(element); - const {transform, transformOrigin} = getComputedStyle(element); + const {transform, transformOrigin} = + getWindow(element).getComputedStyle(element); if (transform) { rect = inverseTransform(rect, transform, transformOrigin); diff --git a/packages/core/src/utilities/scroll/getScrollableAncestors.ts b/packages/core/src/utilities/scroll/getScrollableAncestors.ts index 395ce0bc..8c0127b1 100644 --- a/packages/core/src/utilities/scroll/getScrollableAncestors.ts +++ b/packages/core/src/utilities/scroll/getScrollableAncestors.ts @@ -41,8 +41,7 @@ export function getScrollableAncestors( return scrollParents; } - const {getComputedStyle} = getWindow(node); - const computedStyle = getComputedStyle(node); + const computedStyle = getWindow(element).getComputedStyle(node); if (node !== element) { if (isScrollable(node, computedStyle)) {