Cannot read property 'offsetTop' of null
See original GitHub issueUsing 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:
- Created 7 years ago
- Comments:7 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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:
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?
Ok, time to check this