This was quite the search before I figured out why I seemingly randomly couldn't tab through any forms.

But, when you enable "edit mode" on a frontend page so all contextual links are visible, and then you go to the backend (where that "edit mode" button isn't even visible and as far as I can remember contextual links aren't even used) a tabbingManager constraints is still being applied. Resulting in essentially no fields being tabbable.

This happens on every form. From node/add to /admin/config/system/site-information. If "edit mode" is enabled, and you check console log with devel_a11y you will see the following constraint active:

TabbingManager: tabbing contraint activated, level 0, 0 tabbable elements, 48 disabled elements.

Which is a constraint that restricts tabbing to only contextual links, of which there are none.

I don't know how to fix it though, Drupal's javascript isn't my forte. I know the constraint is set by AuralView.js (core/modules/contextual/js/toolbar/views/AuralView.es6.js) because the edit mode is still technically enabled, so I'd suggest automatically disabling edit mode when viewing the admin pages or skipping this part when viewing admin pages.

// Create a new tabbing context when edit mode is enabled.
      if (!this.model.get('isViewing')) {
        tabbingContext = Drupal.tabbingManager.constrain($('.contextual-toolbar-tab, .contextual'));
        this.model.set('tabbingContext', tabbingContext);
        this.announceTabbingConstraint();
        this.announcedOnce = true;
      }

This may need escalation to Major, as this essentially breaks the entire backend for the people it was meant to help in the first place.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Grayle created an issue. See original summary.

Grayle’s picture

Component: javascript » contextual.module
Issue summary: View changes
mgifford’s picture

Issue tags: +TabbingManager

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

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

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

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.

larowlan’s picture

Perhaps we deactivate it if there are no items to tab to?

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.

smustgrave’s picture

is it desired to stay enabled? Maybe it defaults to off when page is loaded. If it should stay enabled shouldn't that be a setting somewhere?

smustgrave’s picture

Something like this?

larowlan’s picture

Status: Active » Needs work

Couple of unintended changes in that file

smustgrave’s picture

Sorry! But what do you think about turning that one feature off?

larowlan’s picture

It's there for accessibility, we can't turn it off unconditionally, but maybe we can turn it off if there's no contextual links on the page

smustgrave’s picture

Is it still an accessibility issue if there are contextual links and tabable components on the page?

larowlan’s picture

The intent of the edit button is to trap tabbing to only contextual links when its enabled.

smustgrave’s picture

Gotcha. So the javascript seems to run before the page load. Any suggestion on how to check the contents?

smustgrave’s picture

FileSize
2.01 KB

Thoughts?

smustgrave’s picture

Status: Needs work » Needs review
FileSize
1.87 KB
1.12 KB
1.82 KB

This should hopefully do it.

Status: Needs review » Needs work

The last submitted patch, 22: 2991686-22.patch, failed testing. View results

smustgrave’s picture

The last submitted patch, 24: 2991686-24-tests-only.patch, failed testing. View results

larowlan’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/contextual/js/contextual.toolbar.js
    @@ -32,8 +32,9 @@
    +          localStorage.getItem('Drupal.contextualToolbar.isViewing') !== 'false'
    +            ? true
    +            : !$('body .contextual-region').length,
    

    I think we still need to refine this.
    Steps to reproduce:
    * Visit a page with contextual links, toggle into edit mode
    * Visit a page without contextual links, because it was previously set in your local storage, edit mode remains on and tabbing is broken.

    So in other words, I think we need the lack of contextual region items to trump the local storage option.

  2. +++ b/core/modules/contextual/tests/src/FunctionalJavascript/EditModeTest.php
    @@ -86,6 +100,12 @@ public function testEditModeEnableDisable() {
    +      // Test while Edit Mode is enabled it doesn't interfere with pages with
    +      // no contextual links.
    +      $this->drupalGet('admin/structure/block');
    +      $web_assert->elementContains('css', 'h1.page-title', 'Block layout');
    +      $this->assertGreaterThan(0, $this->getTabbableElementsCount());
    

    We also need a negative assert here that there are no contextual links/regions on this page.

smustgrave’s picture

Status: Needs work » Needs review
FileSize
1.46 KB
2.56 KB

Like this?

mgifford’s picture

Issue tags: +wcag211

Adding WCAG 2.1.1 tag

larowlan’s picture

+++ b/core/modules/contextual/js/contextual.toolbar.js
@@ -31,9 +31,10 @@
+        isViewing: !$('body .contextual-region').length
+          ? true
+          : localStorage.getItem('Drupal.contextualToolbar.isViewing') !==
+            'false',

I found this hard to read - I think we can do this

document.querySelector('body .contextual-region') === null || localStorage.getItem('Drupal.contextualToolbar.isViewing') !== 'false'

and ditch jQuery too

Didn't manually test, but will keep on my list to do so (keeping at NR)

smustgrave’s picture

FileSize
772 bytes
2.41 KB

Made the change in #29 and quick testing shows it still works.

Enabled contextual links on an Article page
Went to /admin/content, where there are no contextual links and could tab normally.

larowlan’s picture

Status: Needs review » Reviewed & tested by the community

Manually tested this and it works as designed.

Before: tabbing doesn't work
After: tabbing works

Thanks for accommodation lots of rounds of feedback here @smustgrave

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 30: 2991686-30.patch, failed testing. View results

smustgrave’s picture

Status: Needs work » Reviewed & tested by the community

Random failure

  • bnjmnm committed 7717f3c5 on 10.1.x
    Issue #2991686 by smustgrave, larowlan, Grayle: Enabling "Edit" to show...
bnjmnm’s picture

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

Who knows how often this tripped someone up? t seems like the kind of problem someone might attribute to their own user error when it's actually a fixable bug. Good fix and solid test coverage in the patch.

I committed to 10.1.x, and I'm checking to see if commit checks pass for 10.0.x to cherry-pick to account for any possible lint/formatting requirements.

  • bnjmnm committed d05e452f on 10.0.x
    Issue #2991686 by smustgrave, larowlan, Grayle: Enabling "Edit" to show...
bnjmnm’s picture

Version: 10.0.x-dev » 9.5.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Cherry picked this to 10.0.x. This addresses a bug that could otherwise be quite frustrating, so backporting this to 9.5.x would be nice to do. This will need a 9.5.x specific patch as 9x requires .es6.js files. Setting issue status to "Patch (to be ported)" and the provider of the patch can switch back to RTBC or Needs Review (depending on their patch-porting confidence level)

Gauravvvv’s picture

Status: Patch (to be ported) » Needs review
FileSize
3.13 KB

I have attached patch for 9.5.x. please review

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 38: 2991686-38.patch, failed testing. View results

smustgrave’s picture

Status: Needs work » Reviewed & tested by the community

Random failure

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 38: 2991686-38.patch, failed testing. View results

Anandhi Karnan’s picture

Fixed test failures, please review.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

So even if it's a random failure we wouldn't solve it here. It would need to be it's own ticket.

Also the patch in #43 doesn't include the original patch so hiding that.

The last submitted patch, 38: 2991686-38.patch, failed testing. View results

mgifford’s picture

larowlan’s picture

Version: 9.5.x-dev » 10.0.x-dev
Status: Reviewed & tested by the community » Fixed

9.5 is now security only, so marking this as fixed and moving version to 10.0

Status: Fixed » Closed (fixed)

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