question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property 'offsetTop' of null

See original GitHub issue

Using Ember 2.7 and ember-power-select 1.0.0-beta.12, I have two basic selects set up like this:

{{#power-select
  selected=vendor.country
  options=countries
  searchField='name'
  onchange=(action 'chooseCountry' vendor)
  as |country|
}}
  {{country.name}}
{{/power-select}}

{{#power-select
  selected=vendor.state
  options=states
  searchField='name'
  onchange=(action (mut vendor.state))
  as |state|
}}
  {{state.name}}
{{/power-select}}

I’ll click on one, the options list opens, then, without closing it, I’ll click on the other select, get the mentioned error in console while the other options list opens, and I’ll get a Cannot read property 'offsetTop' of null error in console. After this, I can’t close the second options list no matter what I try and basically both selects are unusable (also unable to select items).

I tried to set up a demo of this on ember-twiddle, but I’m not sure it supports addons quite yet.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
michalsnikcommented, Aug 26, 2016

I think know exactly what causes issue now: When one of the dropdown has selected element which index is bigger than number of items in other select component, when you open the “smaller” select and without closing it try to open the one that has already selected element with bigger index - it crashes.

It looks like the function scrollTo is looking for an element on opened list with index that is already selected on other select component. At least it looks like so.

I’m trying to find a proper solution now.

Update:

optionsList = self.document.querySelectorAll('.ember-power-select-options')

This returns a wrong list - the one that was not closed and not the new one. Clearly there is no item with index that was selected on the second select so it throws an error, as there is no offsetTop on undefined. I think that opened list should be closed before executing scrollTo() on another - then everything would be all right. What do you think?

1reaction
cibernoxcommented, Aug 26, 2016

Ok, time to check this

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught TypeError: Cannot read property 'offsetTop' of null
Currently you are trying to access the element with the id myTopnav when the browser hasn't parsed the HTML yet, which means your...
Read more >
TypeError: Cannot read property 'offsetTop' of Null in JS
The "Cannot read property 'offsetTop' of null" error occurs when trying to access the offsetTop property on a null value. To solve the...
Read more >
Uncaught TypeError: Cannot read property 'offsetTop' of null #14
I'm getting multiple console errors saying 'Uncaught TypeError: Cannot read property 'offsetTop' of null'. Is there a fix for this?
Read more >
Type error: Cannot read property offsetTop of null react ...
Coding example for the question Type error: Cannot read property offsetTop of null react. Unmounted component-Reactjs.
Read more >
reactjs typeError: Cannot read property 'offsetHeight' of null
reactjs typeError : Cannot read property 'offsetHeight' of null. Mike Philip. handleResize = () => { let highestSlide = 0; this.refArray.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found