Skip to content

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

@SumaiyaaRq

Description

@SumaiyaaRq

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 menuPanel elements gracefully without throwing an error.

Screenshots

Screenshot 2024-11-01 at 12 22 37 AM

Suggested Fix:

Adding checks to see if menuButton and menuPanel exist before using them.

Environment

  • OS: (macOS)
  • Browser: (Chrome)

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:

  • Remove the Code: If the menu functionality is entirely unnecessary, the cleanest solution is to remove the related code. This avoids unnecessary checks and potential errors.
  • Use Conditional Code: If the menu might be added in the future or conditionally in specific layouts, you can leave the code with null checks to ensure it only runs when the elements are present.

Resolution

  • I would be interested in resolving this bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions