The primary navigation uses JS to handle interactions and initialize. The events are added when the document is loaded, which could potentially become an issue if the menu is injected into the DOM by BigPipe at a later time. To work around this, we should use Drupal Behaviors.

Comments

mherchel created an issue. See original summary.

kostyashupenko’s picture

Status: Active » Needs review
StatusFileSize
new13.13 KB
kostyashupenko’s picture

StatusFileSize
new13.07 KB
new1.43 KB
mherchel’s picture

Status: Needs review » Needs work

At first glance this is a refactor of beauty! I have a couple nitpicks below since we're refactoring the whole thing. I know that most of these are leftovers from the previous code.

Note that I'm still going to do some additional cross browser and device testing. But I don't see anything that looks like it would cause issues.

Thanks!

  1. +++ b/js/navigation.js
    @@ -6,85 +6,97 @@
    +      if (e.keyCode === 27) {
    

    Some cleanup. We can use e.key === "Escape" here.

  2. +++ b/js/navigation.js
    @@ -6,85 +6,97 @@
    +      if (e.key === 'Tab' || e.keyCode === 9) {
    

    Once again, we only need e.key

  3. +++ b/js/navigation.js
    @@ -6,85 +6,97 @@
    +      var mobileNavWrapper = context.querySelector('#' + mobileNavWrapperId + ':not(.js-' + mobileNavWrapperId + ')');
    

    These variable names seem a bit off to me. The header-nav element wraps all of the navigation (mobile and wide). Maybe just call it "navWrapper"?

  4. +++ b/js/navigation.js
    @@ -6,85 +6,97 @@
    +        mobileNavWrapper.classList.add('js-' + mobileNavWrapperId);
    

    We shouldn't use the js- to indicate that this is processed, the js- prefix is used for selectors that JavaScript will be using. Maybe something like "processed-". Not sure if Drupal has a convention for this type of stuff.

mherchel’s picture

Tested both regular and mobile navigation across Chrome, FF, Safari, and IE11. Works great!

kostyashupenko’s picture

Status: Needs work » Needs review
StatusFileSize
new12.83 KB
new10.66 KB
mherchel’s picture

Status: Needs review » Reviewed & tested by the community

Looking good!

+++ b/js/navigation.es6.js
@@ -1,100 +1,135 @@
+      if (e.key === 'Tab' || e.key === 9) {

I'm fixing this on commit!

mherchel’s picture

Status: Reviewed & tested by the community » Fixed

Committed! Thanks!

kostyashupenko’s picture

Status: Fixed » Needs review
StatusFileSize
new813 bytes

Re-openning, since you forgot to run yarn build:js looks like

mherchel’s picture

Status: Needs review » Fixed

Re-closing since yarn:build has been run, committed, etc.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.