canonical / vanilla-framework

From community websites to web applications, this CSS framework will help you achieve a consistent look and feel.
https://vanillaframework.io
GNU Lesser General Public License v3.0
798 stars 163 forks source link

Navigation scripts are not well-encapsulated #5180

Open jmuzina opened 1 week ago

jmuzina commented 1 week ago

Describe the bug

The JS scripts used by the navigation pattern do not work properly when there are multiple navigation components on the screen. This introduces issues for #5165 , where we would like the nav component to be fully interactive in combined form, just as it is in singular form.

To Reproduce

Steps to reproduce the behavior:

  1. Add multiple navigation components to the same page. Import the same navigation scripts in each component separately. A good way to do this is to checkout the combined navigation PR and then revert the commit that disabled its interactivity.
  2. Observe console error:
    Uncaught SyntaxError: redeclaration of const initNavigationSliding

Expected behavior

Multiple imports of the navigation scripts should not cause errors. The component's script should be encapsulated such that there can be multiple indepedent navigation components on the same DOM.

Further context MM thread