scroll-into-view / scroll-into-view-if-needed

Element.scrollIntoView ponyfills for things like "if-needed" and "smooth"

Home Page:https://scroll-into-view.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot read property 'clientHeight' of undefined

fcurts opened this issue Β· comments

2.2.8 is the last version that works for me (tried both Chrome and Safari). 2.2.9 and all later versions fail with:

scroll-into-view.min.js:1 Uncaught TypeError: Cannot read property 'clientHeight' of undefined
    at n (scroll-into-view.min.js:1)
    at r (scroll-into-view.min.js:1)
    at scroll-into-view.min.js:1

Here is the failing invocation (elem is neither undefined nor null):

scrollIntoView(elem, {
        behavior: 'instant',
        scrollMode: 'if-needed',
        block: 'nearest',
        inline: 'nearest',
      });

Figured it out. Was trying to scroll to an element before it had been added to the DOM. Apparently this works or is a no-op in 2.2.8 but fails in later versions.

Interesting! I’m going to re-open this issue and investigate how native browsers handle this, and if it’s included in the CSSOM View spec what should happen.

IMO we should either no-op or provide a better error message than "clientHeight" on undefined πŸ€”

Hi @stipsan is there any update on this? We are using this plugin but because of this bug we may have to find another solution if this doesn't get fixed soon so hoping your close to releasing a fix? Thanks!

πŸŽ‰ This issue has been resolved in version 2.2.17 πŸŽ‰

The release is available on:

Your semantic-release bot πŸ“¦πŸš€

@bluecaret please let me know if v2.2.17 didn't solve it πŸ™‚

Awesome! Glad I said something ;) I'll take a look tomorrow. Thanks for the fast reply and work!

@stipsan It worked great! And FYI we are using the smooth-scroll addon so it works with that as well. Thanks again!

Great to hear! πŸŽ‰