Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error cannot read properties of null (reading 'scrollTop') #6949

Closed
ahmedrowaihi opened this issue Jun 15, 2024 · 3 comments
Closed

error cannot read properties of null (reading 'scrollTop') #6949

ahmedrowaihi opened this issue Jun 15, 2024 · 3 comments

Comments

@ahmedrowaihi
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch sanity@3.45.0 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/sanity/lib/index.mjs b/node_modules/sanity/lib/index.mjs
index c8fb18c..d29aff6 100644
--- a/node_modules/sanity/lib/index.mjs
+++ b/node_modules/sanity/lib/index.mjs
@@ -795,7 +795,7 @@ const getOffsetsTo$1 = (source, target) => {
   };
   let foundScrollContainer = !1, el = source;
   for (; el && el !== target && target.contains(el); )
-    foundScrollContainer && (bounds.top += el.offsetTop, bounds.left += el.offsetLeft), hasOverflowScroll(el) && (bounds.top = el.offsetTop, bounds.height = el.offsetHeight, bounds.left = el.offsetLeft, bounds.width = el.offsetWidth, foundScrollContainer = !0), rect.top += el.offsetTop - el.scrollTop, rect.left += el.offsetLeft - el.scrollLeft, el = el.offsetParent;
+    foundScrollContainer && (bounds.top += el.offsetTop, bounds.left += el.offsetLeft), hasOverflowScroll(el) && (bounds.top = el.offsetTop, bounds.height = el.offsetHeight, bounds.left = el.offsetLeft, bounds.width = el.offsetWidth, foundScrollContainer = !0), rect.top += el.offsetTop - (el?.scrollTop || 0), rect.left += el.offsetLeft - el.scrollLeft, el = el.offsetParent;
   return { rect, bounds };
 };
 function isChangeBar(v) {
@@ -8408,6 +8408,7 @@ function group(regionsWithIntersectionDetails) {
   };
 }
 const Spacer = ({ height, ...rest }) => /* @__PURE__ */ jsx("div", { style: { height: Math.max(0, height), ...rest == null ? void 0 : rest.style } }), DEFAULT_MARGINS$1 = [0, 0, 0, 0], getOffsetsTo = (source, target) => {
+  if(!el) return { top:0, left:0 };
   let el = source, top = -el.scrollTop, left = 0;
   for (; el && el !== target; )
     top += el.offsetTop - el.scrollTop, left += el.offsetLeft, el = el.offsetParent instanceof HTMLElement ? el.offsetParent : null;

This issue body was partially generated by patch-package.

@binoy14
Copy link
Contributor

binoy14 commented Jun 17, 2024

This has been fixed in v3.46.1

@linear linear bot closed this as completed Jun 17, 2024
@runeb
Copy link
Member

runeb commented Jun 18, 2024

Thank you for the report and the suggested patch @ahmedrowaihi! As you hopefully got notification of, we already fixed this particular issue in a recent version.

Copy link
Contributor

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants