We need to refactor navigation.es6.js to meet Drupal's JS coding standards

  • We need to convert navigation.es6.js to use regular JavaScript selectors to using attribute selectors where possible. For attributes, we should use data-drupal-selector="selector-name"
  • We should use SMACSS style is- selectors to indicate state (see https://css-tricks.com/bem-101/#:~:text=%2F*%20btn%20module%20with%20sta...)
  • We have one instance of adding a keyup event listener for Escape that will not work in IE11

Comments

mherchel created an issue. See original summary.

mherchel’s picture

Title: Olivero: Normalize JavaScript selectors in navigation.es6.js » Olivero: Refactor navigation.es6.js to meet Drupal's JavaScript coding standards
Issue summary: View changes

Updating scope

mherchel’s picture

Status: Active » Needs review
StatusFileSize
new17.67 KB

Patch attached. Several CSS files and another JS file were also modified when adjusting the selectors.

Tugboat preview at https://3212981-refactor-navigation-js-6mvrgpr2ci8ntkdg9ksdsev5t07t1aut....

gauravvvv’s picture

Status: Needs review » Reviewed & tested by the community

js-fixed class for the header is changed to is-fixed and js-overlay-active to is-overlay-active in patch #2.

The fixed header is working fine. This can be move to RTBC

lauriii’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs review
StatusFileSize
new2.2 MB

Was these left unchanged on purpose?


mherchel’s picture

Was these left unchanged on purpose?

Yes. Those are being changed in #3212981: Olivero: Refactor navigation.es6.js to meet Drupal's JavaScript coding standards

andy-blum’s picture

@mherchel the issue you reference in #7 is this issue.

mherchel’s picture

Status: Needs review » Needs work

Yeah you're right! I created a circular dependency. I do believe those need to be updated.

mherchel’s picture

StatusFileSize
new17.5 KB

Re-roll attached.

mherchel’s picture

Status: Needs work » Needs review
StatusFileSize
new20.74 KB
new3.25 KB
thejimbirch’s picture

Status: Needs review » Reviewed & tested by the community

We need to convert navigation.es6.js to use regular JavaScript selectors to using attribute selectors where possible. For attributes, we should use data-drupal-selector="selector-name"

- This is addresses throughout the patch.

We should use SMACSS style is- selectors to indicate state (see https://css-tricks.com/bem-101/#:~:text=%2F*%20btn%20module%20with%20sta...)

- From #6, this now returns no results: grep -r 'js-fixed' core/themes/olivero

We have one instance of adding a keyup event listener for Escape that will not work in IE11

- This is addressed on line 363.

Marking as RTBC.

andy-blum’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new1.82 MB

There is one small issue on IE11.

The escape key does exit the navigation, but it does not return focus to the dropdown arrow. See attached recording

mherchel’s picture

Status: Needs work » Needs review

@andy-blum, that is addressed in #3210443: Olivero: Focus after submenu close via ESC key, which is not yet committed.

andy-blum’s picture

Status: Needs review » Reviewed & tested by the community

Then RTBC!

The last submitted patch, 10: 3212981-10-reroll.patch, failed testing. View results

lauriii’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/themes/olivero/js/navigation.js
@@ -32,7 +32,7 @@
-      if (e.key === 'Escape') {
+      if (e.key === 'Escape' || e.key === 'Esc') {

This seems like a bug which we should solve in a separate issue and make sure it's properly tested. Other than that, this looks good 👍

mherchel’s picture

Status: Needs work » Needs review
StatusFileSize
new1.08 KB
new20.02 KB

This seems like a bug which we should solve in a separate issue and make sure it's properly tested.

Code is removed, but not sure if we can test this at all. All of our tests use Chromium, and AFAIK there's no way for Nightwatch to pass an invalid key.

mherchel’s picture

indrajithkb’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new47.37 KB
new53.47 KB
new50.52 KB
new74.46 KB

Hi @mherchel i have checked the #18, Now the 'js-fixed' changed to 'is-fixed' and 'js-overlay-active' to 'is-overlay-active'.

Before patch we have 'js-fixed' and 'js-overlay-active':

image

image

After patch we have 'is-fixed' and 'is-overlay-active'

image

image

Moving to RTBC

  • lauriii committed 34633c2 on 9.3.x
    Issue #3212981 by mherchel, Indrajith KB, Gauravmahlawat, andy-blum,...

  • lauriii committed 6158c17 on 9.2.x
    Issue #3212981 by mherchel, Indrajith KB, Gauravmahlawat, andy-blum,...
lauriii’s picture

Version: 9.3.x-dev » 9.2.x-dev
Status: Reviewed & tested by the community » Fixed

Committed 34633c2 and pushed to 9.3.x. Also cherry-picked to 9.2.x since Olivero is experimental. Thanks!

Status: Fixed » Closed (fixed)

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