[Bug] referenceButtons creates errors when undefined
AmasiaNalbandian opened this issue · 1 comments
Version
BS5
Reproduction link
Operating System
Windows/OS
Device
PC
Browser & Version
Chrome Version 97.0.4692.99
Steps to reproduce
ReferenceButtons is not always defined, See
.We should protect this.
What is expected?
There should not be any errors in console due to undefined variables.
What is actually happening?
Error in console:
Uncaught TypeError: Cannot read properties of null (reading 'classList') at 'navbarColorOnResize.
Solution
use optional chaining as below:
if (referenceButtons?.classList.contains('active') && referenceButtons?.getAttribute('data-class') === 'bg-transparent') {
Additional comments
I'd be happy to contribute the fix for this.
Hello @AmasiaNalbandian,
Thank you for using our products and for your solution to this issue. We are preparing an upgrade for this product this week, so if you want to contribute, please create a PR or we will integrate your solution in this next update.
Please let us know if we can help you with anything else.
All the best,
Stefan