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

Cannot read property 'isEqualNode' of null #405

Closed
zahorovskyi opened this issue Dec 24, 2019 · 21 comments
Closed

Cannot read property 'isEqualNode' of null #405

zahorovskyi opened this issue Dec 24, 2019 · 21 comments

Comments

@zahorovskyi
Copy link

zahorovskyi commented Dec 24, 2019

Hi @fisshy !
I found an issue and I assume that it's related to these changes:
6c02a59
@borunovm Could you check it, please?

image

@borunovm
Copy link
Contributor

Hello!
Thank you for the review and found the issue. I will check it tomorrow.

@borunovm
Copy link
Contributor

Hello!
Please send me a piece of code how do you use react-scroll?

@borunovm
Copy link
Contributor

I checked in various cases. I couldn't get this issue.
Please, send me a piece of your code.
I will try to fix it.

@mkantz84
Copy link

mkantz84 commented Dec 25, 2019

same issue here.
version: 1.7.13 and 1.7.15

this is how i use it:

scroller.scrollTo('scrollHere', {
   duration: 300,
   smooth: true,
   containerId: `priorityElementID_${configurationId}`
 })
...
...
<Element name="scrollHere"></Element>

@borunovm
Copy link
Contributor

It is should work. I created the same code and checked it. It works for me.
I am sorry.

You should verify the existence of the container.

@mkantz84
Copy link

the container exists.
when i changed the method calculatingOffsetParent in utils.js to:

var calculatingOffsetParent = function calculatingOffsetParent(c, t) {
  return t && t.offsetParent && t.offsetParent.isEqualNode(c) ? t.offsetTop : t ? t.offsetTop + calculatingOffsetParent(c, t.offsetParent) : null;
};

the problem fixed.
I dont know the consequences for the change, but maybe it could help you by finding the problem..
Note - on version 1.7.13, everything was OK. suddenly, after new installation (same version) it broke.
I tried downgrading to 1.7.12, but it still happens.

@borunovm
Copy link
Contributor

Thank you for help. I know how I can fix this method. But I don't know how can I get this issue.

I don't know why you are getting this issue and what caused it.

I will test this method tomorrow and add additional checks

@borunovm
Copy link
Contributor

I improved the condition and hope that this solves the issue.

@karthikvrao
Copy link

Thank you for help. I know how I can fix this method. But I don't know how can I get this issue.

I don't know why you are getting this issue and what caused it.

I will test this method tomorrow and add additional checks

I am facing the same issue on the latest version 1.7.15.
@borunovm please see if this codesandbox example is helpful.

It is the basic example from the repo in which I have just commented out most of the code not related to scrolling inside container. With default v1.7.7 it works but if you update to latest version it doesn't.

You may setup the same code locally to the see the error in console.

@karthikvrao
Copy link

I also noticed that though the 'scrollTo' action itself works from v1.7.8 to v1.7.14, the offset (position where it scrolls to) is not correct as it overshoots.

@mstykow
Copy link

mstykow commented Jan 4, 2020

I improved the condition and hope that this solves the issue.

It did not.

@LockhartJasonA
Copy link

I just wanted to add a comment that I am experiencing this issue as well as of 1.7.15, reverting to 1.7.14 fixes my code.

I am using the Link component // wrapper to navigate to the Element component wrapper.

utils.js:30 Uncaught TypeError: Cannot read property 'isEqualNode' of null
at e (utils.js:30)
at Object.scrollOffset (utils.js:34)
at Object.scrollTo (scroller.js:86)
at scrollTo (scroll-link.js:211)
at handleClick (scroll-link.js:232)
at Object. (react-dom.production.min.js:80)
at _ (react-dom.production.min.js:100)
at react-dom.production.min.js:104
at E (react-dom.production.min.js:124)
at N (react-dom.production.min.js:152)

@fisshy
Copy link
Owner

fisshy commented Jan 7, 2020

I believe I've solved the issue here.

https://github.com/fisshy/react-scroll/tree/pre-1.7.15

Checkout this branch, and I will merge it later.

@borunovm
Copy link
Contributor

borunovm commented Jan 7, 2020

I don't see the changes

@fisshy
Copy link
Owner

fisshy commented Jan 7, 2020

Now, it helps to actually push them ;D

@gino8080
Copy link

seems broken with latest react ^16.12.0

@Benji-Leboe
Copy link

Benji-Leboe commented Jan 15, 2020

Hey guys, so after struggling with this issue all day, I think I've found the solution.

The .offsetParent property looks for the nearest non-static ancestor. That means that if your scroll container and the parent element that contains your doesn't have an explicitly set position and the nearest non-static ancestor they both share happens to be the same element, the calculatingOffsetParent function recurses until it hits the body (which of course has an .offsetParent of null)

For a stopgap solution set the position of your container element and the parent of your explicitly to something other than static.

I'm not sure what changed or why it worked before, but I got it working again after going nearly insane trying to solve this

@cursedcoder
Copy link

reverting to the old version does the trick

@fisshy
Copy link
Owner

fisshy commented Jan 17, 2020

Try the new version

@Reggino
Copy link

Reggino commented Jan 17, 2020

The new version fixes it!

@deltek-rossjackson
Copy link

It also fixed our issue. thank you.

@fisshy fisshy closed this as completed Jan 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests