ui
ui copied to clipboard
[Bug] referenceButtons creates errors when undefined
Version
BS5
Reproduction link
https://github.com/Seneca-CDOT/telescope/issues/2691
Operating System
Windows/OS
Device
PC
Browser & Version
Chrome Version 97.0.4692.99
Steps to reproduce
ReferenceButtons is not always defined, See https://github.com/creativetimofficial/material-dashboard/blob/66716686d10a8f1ed754f93bb52b3a922db1ffcf/assets/js/material-dashboard.js#L626.
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.