Javascript error in select.ts openChange() when control is destroyed
jcachat opened this issue · 4 comments
I am getting occasional javascript errors such as the following:
null is not an object (evaluating 'document.getElementById(this.ngSelect.dropdownId).classList')
at classList (projects/extensions/select/select.ts:592:18)
at this (zone.js/fesm2015/zone.js:1767:43)
at target (webpack:///../packages/core/src/zone/ng_zone.ts:415:36)
at this (zone.js/fesm2015/zone.js:158:58)
at task (zone.js/fesm2015/zone.js:479:42)
It looks to be in extensions/projects/extensions/select/select.ts in the openChange() method. That is setting the classList inside a setTimeout. I believe it's a timing issue if the select is open and the control is destroyed. This line is probably returning null.
const dropdownEl = document.getElementById(this.ngSelect.dropdownId) as HTMLElement;
Could you add a null check there?
Can you provide an online example?
Unfortunately, I can't. It is happening in my production enterprise app. It is not something I can share, it's a timing issue, does not happen often, and I don't have a minimal reproduction.
The stack trace I provided was directly from the production system. It is clearly pointing at the line of code I indicated and the use of a setTimeout provides the opportunity for the control to be destroyed before the timeout handler executes.
18.2.3 has fixed, please have a try.
Thank you very much! I really appreciate the quick response and your work on this library. I have the update integrated and see no issues so far. I'm sure this will fix the error I have seen so you can close this issue.