Problem/Motivation

If active tab is not on the first position, then when dropdown is expanded on small resolutions - it may have the wrong position

Steps to reproduce:

1. Browse to a page (with a wide viewport) that has multiple tab pages handled by Olivero (the "login" page works along with "create new account", and "reset password" pages)
2. Navigate to a tab that is not in the first position (such as "create new account").
3. Resize your browser window to activate the mobile tabs
4. Expand the tabs. Note that "create new account" is not the first item.

Mobile tabs
Mobile expanded tabs

CommentFileSizeAuthor
#71 3129257-after_patch.png19.49 KBAbhijith S
#71 3129257-before_patch.png20.1 KBAbhijith S
#70 interdiff-66-70.txt1.02 KBmherchel
#70 3129257-70.patch5.14 KBmherchel
#70 3129257-70-test-only-FAIL.patch1.02 KBmherchel
#67 Screenshot 2021-04-11 at 11.07.31.png20.3 KBGauravvvv
#67 Screenshot 2021-04-11 at 11.05.52.png22.44 KBGauravvvv
#66 3129257-65.patch4.11 KBmherchel
#65 3208116.patch4.03 KBmherchel
#61 interdiff_58-61.txt216 byteskishor_kolekar
#61 3129257-61.patch5.4 KBkishor_kolekar
#60 interdiff_58-59.txt216 byteskishor_kolekar
#60 3129257-59.patch5.4 KBkishor_kolekar
#58 3129257-58.patch5.33 KBravi.shankar
#52 Before_patch_desktop_to_mobile_image.png80.4 KBmanojithape
#51 After_patch_desktop_to_Mobile.png55.64 KBmanojithape
#51 After_patch_desktop.png119.48 KBmanojithape
#51 Before_patch_mobile_to_desktop.png114.9 KBmanojithape
#51 Before_patch_Desktop_to_Mobile.png54.31 KBmanojithape
#47 3129257-47.patch5.16 KBsd9121
#44 after_patch_mobile-to-desktop.png67.05 KBsonam.chaturvedi
#44 after_patch_desktop-to-mobile.png43.51 KBsonam.chaturvedi
#43 Accessibility_tab_order.mov1.54 MBsonam.chaturvedi
#43 after_patch_tab_order.mov1.62 MBsonam.chaturvedi
#43 bef_patch_mobile-to-desktop.png67.84 KBsonam.chaturvedi
#43 bef_patch_desktop-to-mobile.png53.28 KBsonam.chaturvedi
#38 mobile_view_Null error fixed_afterPatch.JPG70.64 KBpankaj.singh
#38 mobile_view_dropdownExpanded_beforePatch.JPG79.28 KBpankaj.singh
#38 mobile_view_beforePatch.JPG31.04 KBpankaj.singh
#38 dsktop_view_beforePatch.JPG36.33 KBpankaj.singh
#36 fixed_tab_order-3129257-36.patch5.99 KBsd9121
#34 tabs-js-error-3129257.png513.71 KBSreenivas Bttv
#32 fix-tab-resize-js-3129257-32.patch5.85 KBsd9121
#32 Screenshot 2020-05-02 at 5.22.07 PM.png72.11 KBsd9121
#29 tab-order-js-3129257-29.patch5.19 KBsd9121
#27 tabs-js-errors-3129257.png171.47 KBSreenivas Bttv
#26 tab-resize-js-3129257-26.patch5.18 KBsd9121
#14 tab-order-accessibility.gif2.75 MBhansa11
#14 tab_order-3129257-14.patch841 byteshansa11
#9 tab_order-3129257-9.patch783 byteshansa11
#8 3129257-desktop_showing_active_tab_first.gif36.7 MBSreenivas Bttv
#6 3129257.gif3.27 MBhansa11
#4 Fix_order_of_the_mobile_tabs-3129257-4.patch719 bytesSreenivas Bttv
Снимок экрана 2020-04-20 в 17.32.24.png23.45 KBkostyashupenko
Снимок экрана 2020-04-20 в 17.31.57.png10.24 KBkostyashupenko

Issue fork drupal-3129257

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kostyashupenko created an issue. See original summary.

mherchel’s picture

This must be a regression. It was working at one point.

hansa11’s picture

Assigned: Unassigned » hansa11
Sreenivas Bttv’s picture

Both in a mobile and desktop active tab showing in the first position only. Might be regression issue in local from @kostyashupenko.
Even though I attached a patch which fixes the tabs-primary active tab order.

kostyashupenko’s picture

It is not regression of my local, you can reproduce it with the following steps:
1. Set Olivero as administration theme
2. Create Article CT node
3. Go to this node page
4. Click on any of the presented tabs (For ex: "Edit" or "Revisions")

@sreenivas-bttv it is bad practice to work on issue when it was assigned to another person 25 minutes ago
Also your patch has an effect to desktop tabs, which is should not. Also this code

+.tabs--primary .tabs__tab {
+  order: 2;
+
+  &.is-active {
+    order: 1;
+  }
+}
+

can be replaced by only one line with negative order: order: -1; for active tab.

hansa11’s picture

FileSize
3.27 MB

@mherchel & @kostyashupenko: This still works fine for me, I don't think we'll need any code change here, please have a look at the gif.

@kostyashupenko: I followed exactly the same steps, but it couldn't be replicated.

tabs

kostyashupenko’s picture

I see.. just understood fully how to reproduce it - load your page in desktop width, then resize your browser window to mobile view, then you will reproduce it

Sreenivas Bttv’s picture

@kostyashupenko,

It's my mistake. I am in edit mode, I thought I changed assigned to me and so continued to add a patch. Immediately noticed someone assigned the ticket. Through the communication channel, I have informed to assigned user.

I cross-checked in desktop, the active tab rendering on the first position in the DOM of specific ul wrapper. So applied the same. If no change requires then it working as expected.

Desktop Active first tab position

hansa11’s picture

Thank you @kostyashupenko, I was able to replicate the issue as mentioned in #7.

The issue exists only when the window is resized from desktop to mobile.

Patch details: Handling this via the order: 0 which is the default value and order: -1 for the smaller screens.

Please review.

Thanks!

hansa11’s picture

Assigned: hansa11 » Unassigned
Sreenivas Bttv’s picture

Noticed in tabs related js (tabs.es6.js) that while initializing tabs the following condition running even on desktop. so it requires js changes.
@hansa11 needs to update js if the active tab position does not require change(first position) for Desktop.

Please check once @kostyashupenko, @mherchel

if (isTabsMobileLayout() && !activeTab.matches('.tabs__tab:first-child')) {
      const newActiveTab = activeTab.cloneNode(true);
      const firstTab = tabs.querySelector('.tabs__tab:first-child');
      tabs.insertBefore(newActiveTab, firstTab);
      tabs.removeChild(activeTab);
    }
kostyashupenko’s picture

Status: Needs review » Needs work

Well,

+  &.is-active {
+    order: -1;
+
+    @media (--md) {
+      order: 0;
+    }
+  }

This code should be executed only when browser has js support enabled, so add html.js selector here.

Also i think the following js can be removed:

if (isTabsMobileLayout() && !activeTab.matches('.tabs__tab:first-child')) {
      const newActiveTab = activeTab.cloneNode(true);
      const firstTab = tabs.querySelector('.tabs__tab:first-child');
      tabs.insertBefore(newActiveTab, firstTab);
      tabs.removeChild(activeTab);
    }

Since we can deal it by order: -1; for the active tab.

hansa11’s picture

Assigned: Unassigned » hansa11

Thank you for your review @kostyashupenko :)

I am gonna take a look at this.

hansa11’s picture

Patch details:
1. Added the html.js selector, so the code is executed only when the browser has JS support enabled.
2. I haven't removed the JS, reason being, the order property is only helping us to change the order of the elements visually but in the DOM, the order would still be the same. If we remove the JS and handle it only via CSS, there is a very high possibility that users with vision impairment will continue to move forward being unaware of some of the previous links. Also, there is very little possibility that someone with vision impairment will ever resize their screen so the issue mentioned in #7 should be fixed via CSS (as suggested by @kostyashupenko ) without making any changes to the JS code.

I'll try to explain this with a gif here.

tab order accessibility

Please review :)

Thanks!

hansa11’s picture

Assigned: hansa11 » Unassigned
Status: Needs work » Needs review
kostyashupenko’s picture

Status: Needs review » Needs work

Hm.. make sense @hansa11, you are right. I just checked how it was done in Claro, and it is resolved there by js when browser window got resize. So better to fix this issue on js side only, instead of adding "order: -1";

mherchel’s picture

Yeah, when order is implemented, it doesn't change the tabbing order. Which is an accessibility issue (according to the core maintainers).

hansa11’s picture

Assigned: Unassigned » hansa11

I'll take a look at this using JS now.

sd9121’s picture

@hansa11 Have you already started on it, if not can I take this, I have some bandwidth today. Please let me know on this.

sd9121’s picture

sd9121’s picture

sd9121’s picture

sd9121’s picture

hansa11’s picture

Assigned: hansa11 » Unassigned

@sd9121: I haven't started on it yet, I've been very occupied on client projects since morning today, sure please feel free to pick this up. :)
I'll unassign it.

sd9121’s picture

Assigned: Unassigned » sd9121
sd9121’s picture

Assigned: sd9121 » Unassigned
Status: Needs work » Needs review
FileSize
5.18 KB

1. On resizing the screen from desktop to mobile the selected tab will move to the top.
2. On resizing the screen from mobile to desktop, all the tabs will move back to their original DOM order.

Please review.

Sreenivas Bttv’s picture

Status: Needs review » Needs work
FileSize
171.47 KB

@sd9121,

Your #26 patch working well in terms of functionality. But few errors need to correct. While initial DOM loading, still links and their classes were not added to that ul/tabs and those causing 2 javascript errors.

Please check the screenshot for more details.
js errors

Also, minor code readability adjustments required in tabs.es6.js file (optional)

@kostyashupenko @mherchel apart from 2 errors, the patch is good to solve the issue.

sd9121’s picture

Assigned: Unassigned » sd9121
sd9121’s picture

Assigned: sd9121 » Unassigned
Status: Needs work » Needs review
FileSize
5.19 KB

Resolved the above error.

Sreenivas Bttv’s picture

Status: Needs review » Needs work

@sd9121,

Still, the #29 patch does not solve the issues mentioned in #27 comment.

We have majorly two types of tabs are there.
1. Primary
2. Secondary

To produce the error, please navigate to appearance settings (admin/appearance/settings) where we can see both primary and secondary tabs.

As per existing tabs js code,

We are calling clientHeight for all [data-drupal-nav-tabs] through context.querySelectorAll.

But where Button with class name tabs__trigger only available for primary.
(templates/navigation/menu-local-task.html.twig)

So in isTabsMobileLayout clientHeight calling for secondary tabs too. Also, adding addEventListener on null.
So please check all the above scenarios.

sd9121’s picture

Assigned: Unassigned » sd9121
sd9121’s picture

@sreenivas: Thank you for the review. The design for primary and the secondary tabs is completely different, I don't think we should make the secondary tabs similar to that of primary tabs, it would be bad in User experience, but yes, I have added a condition here if the class tabs__trigger is available only then the JS should be applied, that will fix the error you mentioned.

image

This patch should fix this error.

sd9121’s picture

Assigned: sd9121 » Unassigned
Status: Needs work » Needs review
Sreenivas Bttv’s picture

Status: Needs review » Needs work
FileSize
513.71 KB

@sd9121,

Still, #32 patch not fixing errors mentioned earlier. As mentioned in your comment, I am not saying secondary tabs should similar to Primary tabs.

But as mentioned earlier below code runs for both Primary and secondary tabs.

 context.querySelectorAll('[data-drupal-nav-tabs]').forEach(el => {
     return init(el);
 });

Now the problem is different.

  • where calling insideAfter, passing parameter previous as null. Please check siblings.
  • On window resize function, trying get attribute for tabs which is invalid.
    tabs.querySelector('.is-active').getAttribute('data-original-order') > 0 
    

Still, in console, we can notice the null error for insertAfter and window resize functions. Please check the screenshot for more details.

js error

sd9121’s picture

Version: » 8.x-1.0-alpha2
Assigned: Unassigned » sd9121
sd9121’s picture

Assigned: sd9121 » Unassigned
Status: Needs work » Needs review
FileSize
5.99 KB

Please review the updated patch.

pankaj.singh’s picture

Assigned: Unassigned » pankaj.singh
pankaj.singh’s picture

Tested the issue, but not able to reproduce the same, it works fine for me. Ther order of menu items are appearing correctly.
However, in the console, we can notice the null error.

After applying the patch given in #36, the null error got fixed.

ambuj_gupta’s picture

Assigned: Unassigned » ambuj_gupta
ambuj_gupta’s picture

Assigned: ambuj_gupta » Unassigned
steinmb’s picture

Version: 8.x-1.0-alpha2 » 8.x-1.x-dev

Reading through the comments but I have a little problem understanding. From my understanding is there not a issue with order of menu in latest dev. (the original reported issue) but there are JS warnings that goes away with the latest patch? Not sure how to review it.

sonam.chaturvedi’s picture

Assigned: Unassigned » sonam.chaturvedi
sonam.chaturvedi’s picture

Assigned: sonam.chaturvedi » Unassigned
Status: Needs review » Reviewed & tested by the community
FileSize
53.28 KB
67.84 KB
1.62 MB
1.54 MB

Verified and tested patch#36. Patch applied successfully and looks good to me.

Testing Steps:
1. Install Olivero Theme
2. Set Olivero Theme as Administration theme
3. Create Article CT node
4. Goto this node page on desktop
5. Click on any of the presented tabs (For ex: "Edit")
8. Resize the screen from desktop to mobile
9. Check active/selected tab is not on first position
10. Now click on other tab (For ex: "Revision")
11. Resize the screen from mobile to desktop
12. Check all the tabs do not move back to their original DOM order
13. Now apply the patch
14. Check tabbing order on window resize is fixed

Testing Results:
1. On resizing the screen from desktop to mobile > The selected tab moves to the top.
2. On resizing the screen from mobile to desktop > The tabs move back to their original DOM order.
3. No console error is displayed
4. Accessibility test - Tabbing order is correct on mobile using TAB key

Before Patch:
before patch

bef patch m to d

sonam.chaturvedi’s picture

mherchel’s picture

Status: Reviewed & tested by the community » Needs work

Thanks for all the work on this. I didn't test this out, but I did review the code and have some thoughts.

1) My understanding is that this issue only happens if the page was loaded on desktop, and then is resized to mobile. If this is correct, is this worth the added technical debt? This isn't an issue that people will run into in real life, and in the event that someone does 10 years down the line, the tabs are still usable.

2) I reviewed the code and have some thoughts. The main issue that I see is that the resize event listener will be added each time the behavior runs.

  1. +++ b/js/tabs.es6.js
    @@ -19,22 +25,60 @@
    +      window.addEventListener('resize', () => {
    

    Correct me if I'm wrong, but won't this add an event listener for each time the behavior is run? I believe this should be outside of behaviors.

  2. +++ b/js/tabs.es6.js
    @@ -19,22 +25,60 @@
    +              .getAttribute('data-original-order') > 0
    

    I don't believe we need to add the > 0 here.

  3. +++ b/js/tabs.es6.js
    @@ -19,22 +25,60 @@
    +})(Drupal, Drupal.debounce);
    

    Do we need to pass in Drupal.debounce here if we're already pulling in the global Drupal object?

sd9121’s picture

Assigned: Unassigned » sd9121
sd9121’s picture

Assigned: sd9121 » Unassigned
Status: Needs work » Needs review
FileSize
5.16 KB

Thank you @mherchel for reviewing the code.
I have fixed the issue which are mentioned above, Please review my updated patch.

Thanks!

ambuj_gupta’s picture

Assigned: Unassigned » ambuj_gupta
ambuj_gupta’s picture

Assigned: ambuj_gupta » Unassigned
manojithape’s picture

Assigned: Unassigned » manojithape
manojithape’s picture

Verified and tested patch#47. Patch applied successfully and looks good to me.

Testing Steps:
1. Install Olivero Theme
2. Set Olivero Theme as Administration theme
3. Create Article CT node
4. Goto this node page on desktop
5. Click on any of the presented tabs (For ex: "Edit")
8. Resize the screen from desktop to mobile
9. Check active/selected tab is not on first position
10. Now click on other tab (For ex: "Revision")
11. Resize the screen from mobile to desktop
12. Check all the tabs do not move back to their original DOM order
13. Now apply the patch
14. Check tabbing order on window resize is fixed

Testing Results:
1. On resizing the screen from desktop to mobile > The selected tab moves to the top.
2. On resizing the screen from mobile to desktop > The tabs move back to their original DOM order.
3. No console error is displayed
4. Accessibility test - Tabbing order is correct on mobile using TAB key.

manojithape’s picture

FileSize
80.4 KB
manojithape’s picture

Assigned: manojithape » Unassigned
Status: Needs review » Reviewed & tested by the community
andrewmacpherson’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +Accessibility, +Needs accessibility review

Please remember to add the "accessibility" tag to issues which discuss the focus order. The accessibility maintainers likely won't be aware without it.

I'm wary of this one. Tagging for a detailed review with before/after regards to WCAG SC 3.2.3. Consistent Navigation and SC 2.4.3 Focus Order.

Please do not commit this without accessibility maintainer sign-off.

mherchel’s picture

Title: Fix order of the mobile tabs » Olivero: Mobile tabs can become out of order if browser is resized
Project: Olivero » Drupal core
Version: 8.x-1.x-dev » 9.1.x-dev
Component: Code » Olivero theme
Issue summary: View changes
Status: Needs review » Needs work
mherchel’s picture

Issue summary: View changes
mherchel’s picture

Issue summary: View changes
ravi.shankar’s picture

Status: Needs work » Needs review
FileSize
5.33 KB

Rerolled the patch #47.

mherchel’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Patch doesn't apply.

kishor_kolekar’s picture

Status: Needs work » Needs review
FileSize
5.4 KB
216 bytes

here the re-roll patch.

kishor_kolekar’s picture

FileSize
5.4 KB
216 bytes
mherchel’s picture

Status: Needs review » Needs work
Issue tags: -Needs reroll

The patch in #61 breaks the functionality, where if you change tabs in desktop mode, and then switch to mobile, the expand button will not work)

katannshaw made their first commit to this issue’s fork.

mgifford’s picture

Issue tags: +vpat

Linking open issues from the CivicActions Accessibility - VPAT.

mherchel’s picture

Version: 9.1.x-dev » 9.2.x-dev
Status: Needs work » Needs review
FileSize
4.03 KB

Here's a fresh take on a patch (so no interdiff). This approach will create a clone of the active tab (if its not already the first item), and then show/hide the clone and original via CSS at the appropriate breakpoint.

Tugboat URL: coming soon

mherchel’s picture

FileSize
4.11 KB

Attached the wrong patch. Correct patch here.

Gauravvvv’s picture

Patch#66 Verified and tested. Patch applied successfully and looks good to me.

Here adding some before and after patch screenshots for reference.

Gauravvvv’s picture

Status: Needs review » Reviewed & tested by the community
lauriii’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

It seems like this could benefit from some test coverage. Based on #54, we also still need confirmation from the accessibility maintainers on this issue

mherchel’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
1.02 KB
5.14 KB
1.02 KB

Tests added.

Abhijith S’s picture

Applied patch #70 it works fine. Adding screenshots.

Before patch:
before

After patch:
after

RTBC +1

bnjmnm’s picture

I believe this this suggested approach creates problems with WCAG SC 3.2.3. Consistent Navigation, as this changes the tab order depending on viewport size. I also think this exposes a problem with Claro's implementation of this. The current state of these tabs in Olivero is more accessible than anything proposed so far.

I do, however, see the benefits of having the current secondary tab being displayed when the secondary menu is collapsed. I wonder if the confusion comes from this being displayed as a tab, when it's kinda not a tab if it's not adjacent to its sibling tabs. When the secondary tabs are collapsed, this is more akin to a breadcrumb. I think a UX change would be sufficient and less disruptive to site accessibility.

I don't believe this is an accessibility stable blocker, but it could result in a potentially nice UX improvement.

mherchel’s picture

Status: Needs review » Needs work

Discussed with the UX team at #3208186: Drupal Usability Meeting 2021-04-23 and they also gave the OK to remove this as a stable blocker (at least until a holistic solution is created)

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mgifford’s picture

I'm just trying to understand why this is an accessibility error.

For it to occur, the browser would need to be resized, right?

Also, the content is still there, but in a different order, right?

So then it would be about consistent navigation. SC 3.2.3 https://www.w3.org/WAI/WCAG21/Understanding/consistent-navigation.html

Just want to make sure before tagging it.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mgifford’s picture

Issue tags: +wcag323