creativecommons / cc-resource-archive

Collection of resources on Creative Commons (CC) tools and other open topics
https://resources.creativecommons.org/
MIT License
60 stars 133 forks source link

[Bug] Uncaught TypeError in vocabulary.js due to Missing menuButton and menuPanel Elements . #345

Open SumaiyaaRq opened 3 weeks ago

SumaiyaaRq commented 3 weeks ago

Description

I've noticed an issue in vocabulary.js where the code attempts to add an event listener to menuButton and toggle a class on menuPanel, but these elements are not present in the HTML file. This results in an Uncaught TypeError due to trying to call addEventListener on null.

Reproduction

  1. Open the webpage.
  2. Right-click and select Inspect (or press Ctrl+Shift+I / Cmd+Option+I on Mac).
  3. Open the console.
  4. See error.

Expectation

The application should handle the absence of the menuButton and menuPanelelements gracefully without throwing an error.

Screenshots

Screenshot 2024-11-01 at 12 22 37 AM

Suggested Fix:

Adding checks to see if menuButtonand menuPanel exist before using them.

Environment

Additional context

If the menuButton and menuPanel elements aren't needed because the menu functionality is not being used, the best approach might be to:

Resolution

possumbilities commented 3 weeks ago

The newer versions of Vocabulary do null checks here, so this should be corrected as soon as the repository is updated to the latest Vocabulary. Moving to https://github.com/creativecommons/cc-resource-archive/labels/%F0%9F%9A%A7%20status%3A%20blocked until then

SumaiyaaRq commented 3 weeks ago

@possumbilities Thank you for confirming! I had a sense that the latest versions of Vocabulary included null checks, so it’s good to know this will be addressed when the repository is updated.