Problem/Motivation

The uninstall page (admin/modules/uninstall) has a text filter to make it easy to find a module you are interested in.

When filtering the list, Drupal.announce() is used to inform screen reader users how many rows are now shown on the page. However, this announcement is always "0 modules are available in the modified list" no matter whether there are matches or not.

The same Drupal.behaviors.tableFilterByText is used for both the install and uninstall pages, but the page structure is different. It looks like the filter logic only works properly on the install page.

Proposed resolution

Fix the Drupal.announce() message so the module count is correct.

Investigate the jQuery CSS selectors used by system.modules.es6.js to see why the counts passed to Drupal.announce() are wrong.

Remaining tasks

User interface changes

Fixes a bug in a custom screen reader announcement.

API changes

None.

Data model changes

None.

CommentFileSizeAuthor
#36 2923136-36.patch4.31 KB_utsavsharma
#36 interdiff_10-0-x.txt573 bytes_utsavsharma
#35 2923136.35.patch5.09 KB_utsavsharma
#35 interdiff_9-5-x.txt1.34 KB_utsavsharma
#30 2923136-30.patch4.32 KB_utsavsharma
#30 interdiff_26-30.txt586 bytes_utsavsharma
#26 interdiff-2923136-24-26.txt849 bytesyogeshmpawar
#26 2923136-26.patch5.54 KByogeshmpawar
#24 2923136-24.patch5.45 KBranjith_kumar_k_u
#19 interdiff.2923136.17-19.txt1.61 KBwaako
#19 2923136-19.core_.Incorrect-module-count-passed-to-Drupalannounce-on-uninstall-page.patch5.28 KBwaako
#18 drupal-n2923136-18.patch5.18 KBDamienMcKenna
#18 drupal-n2923136-18.interdiff.txt2.27 KBDamienMcKenna
#17 uninstall-prevented.png141.33 KBbnjmnm
#16 interdiff-2923136_14-16.txt869 byteswaako
#16 system-2923136-16-correct_number_of_filtered_results.patch5.22 KBwaako
#14 system-2923136-14-correct_number_of_filtered_results.patch5.28 KBwaako
#8 system-2923136-8-correct_number_of_filtered_results.patch5.09 KBwaako
#7 system-2923136-7-correct_number_of_filtered_results.patch1.57 KBMaskOta
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andrewmacpherson created an issue. See original summary.

andrewmacpherson’s picture

Issue summary: View changes
andrewmacpherson’s picture

andrewmacpherson’s picture

Issue summary: View changes
andrewmacpherson’s picture

This bug falls under the new 3.2.7 Change of Content success criterion from the forthcoming WCAG 2.1

waako’s picture

The problem in system.modules.es6.js is that line 65 $rowsAndDetails.find('tbody tr:visible').length searches for visible rows inside a table.
But $rowsAndDetails as defined Line 88 $rowsAndDetails = $table.find('tr, details'); consists of all table rows and detail elements.

On the Module list/install page each module list table has a category detail wrapper, so that works fine, but on uninstall page, it's just one table, so never finds tbody tr inside tr.

WIthout modifying the markup, I was able to get it working everywhere by using filter instead of find and targeting the visible table rows with [data-drupal-selector] attribute:
Line 88 to { '!modules': $rowsAndDetails.filter('tr[data-drupal-selector]:visible').length }

May be worth categorising modules on uninstall page, to match the markup.

MaskOta’s picture

Version: 8.4.x-dev » 8.5.x-dev
Status: Active » Needs review
FileSize
1.57 KB

Thanks waako for the analysis. Here is the patch based on that.

waako’s picture

Applied patch in #7 It works perfectly.

Added test core/modules/system/tests/src/FunctionalJavascript/ModuleFilterTest.php (inspired from https://www.drupal.org/project/drupal/issues/2715663#comment-11682359).

Only 2 modules are available on uninstall page for testing profile, but still manage to test the following:

  • The filter reduces the number of visible modules
  • The Drupal.announce() message div contains a correct plural message when multiple modules are visible
  • The Drupal.announce() message div contains a correct plural message when one module is visible
  • The Drupal.announce() message div contains a correct plural message when zero modules are visible

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

borisson_’s picture

Status: Needs review » Needs work
+++ b/core/modules/system/tests/src/FunctionalJavascript/ModuleUninstallFilterTest.php
@@ -0,0 +1,87 @@
+  /**
+   *
+   */
+  public function testModuleUninstallFilter() {

This needs an actual comment, not an empty docblock.

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

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.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.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.

waako’s picture

Fixed missing comment in function docblock from #10.
Replaced deprecated JavascriptTestBase with WebDriverTestBase.

Sorry couldn't get an interdiff, original patch wouldn't apply to 8.9.x so had to recreate the changes manually.

Status: Needs review » Needs work

The last submitted patch, 14: system-2923136-14-correct_number_of_filtered_results.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

waako’s picture

I had issues running the tests locally, but finally got it working so was able to better identify issue.
With testing profile, number of preinstalled modules has changed, so removing assertEquals that original module count matches filtered list with string cache as we can't know how many modules will be in the list and if all have a common string.

bnjmnm’s picture

Status: Needs review » Needs work
FileSize
141.33 KB
  1. +++ b/core/modules/system/js/system.modules.es6.js
    @@ -64,9 +64,11 @@
    +            Drupal.formatPlural(
    +              $rowsAndDetails.filter('tbody tr:visible').length,
    +              '1 module is available in the modified list.',
    +              '@count modules are available in the modified list.'
    +            )
    

    There are some JS coding standards not being met here, but they can be fixed automatically with yarn prettier.

  2. +++ b/core/modules/system/tests/src/FunctionalJavascript/ModuleUninstallFilterTest.php
    @@ -0,0 +1,91 @@
    +    $module_rows = $page->findAll('css', '.system-modules-uninstall tbody tr td .module-name');
    

    .module name is the only part of the locator that is necessary here.

  3. +++ b/core/modules/system/tests/src/FunctionalJavascript/ModuleUninstallFilterTest.php
    @@ -0,0 +1,91 @@
    +    self::assertNotEquals(count($module_rows), count($visible_rows));
    

    It's quite possible that using self:: has no adverse effects, but these uses should be changed to $this to be consistent with other FunctionalJavascript tests

  4. +++ b/core/modules/system/tests/src/FunctionalJavascript/ModuleUninstallFilterTest.php
    @@ -0,0 +1,91 @@
    +  /**
    +   * Removes any non-visible elements from the passed array.
    +   *
    +   * @param array $elements
    +   * @return array
    +   */
    +  protected function filterVisibleElements($elements) {
    +    $elements = array_filter($elements, function($element) {
    +      return $element->isVisible();
    +    });
    +    return $elements;
    +  }
    

    There are several coding standards not being met here. The @return and @param need to be separated by a space, the should be descriptions for both, the $elements arg needs a type hint and there should be a space after function. Few have been able to remember all these rules and remain sane. Let code sniffer take care of this for you.

  5. This final item could use some feedback from someone with more accessibility expertise: When filtering modules on the uninstall page, not all of the results are uninstallable. If other enabled modules depend on them, the uninstall option is grayed out and they are not reachable via tab navigation.

    I suspect this could be quite confusing, but not sure if it's in the scope of this specific issue. If it's determined it's not in scope, a followup should get created before this is RTBC.
DamienMcKenna’s picture

Status: Needs work » Needs review
FileSize
2.27 KB
5.18 KB

This includes fixes for items 2 and 3 from comment #17.

waako’s picture

Thanks for the code review feedback bnjmnm, and DamienMcKenna for fixing 2. and 3.

Here's items 1. and 4. updated, likely similar issues with my work at https://www.drupal.org/project/drupal/issues/2715663
I've used the test logic from BlockFilterTest.php for updating the @para and @return as that's what it was inspired from in first place.

With regards to the the filtered results including modules that cannot be uninstalled, I think a follow up issue for discussion is appropriate:
A screen reader can usually list all visible form controls on the page, this will include the disabled checkboxes but on focusing it will announce that it is dimmed/disabled then can read remaining text in table row which explains why module can't be uninstalled.
I can't say if that is good enough, so best discussed in a separate issue.

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.

ranjith_kumar_k_u’s picture

Re-rolled #19 for 9.4

Status: Needs review » Needs work

The last submitted patch, 24: 2923136-24.patch, failed testing. View results

yogeshmpawar’s picture

Status: Needs work » Needs review
FileSize
5.54 KB
849 bytes

Updated patch will fix test failures.

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

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs reroll

This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge require as a guide.

At this time we will need a D10 version of this patch.

_utsavsharma’s picture

Rerolled for 10.1.x.

smustgrave’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs reroll

Removing the Reroll tag.

Testing patch #30 by going uninstall page and doing random filters checking that the announce was updating correctly.

I didn't see a tests-only patch so ran locally without the fix

1) Drupal\Tests\system\FunctionalJavascript\ModuleUninstallFilterTest::testModuleUninstallFilter
Behat\Mink\Exception\ElementTextException: The text "1 modules are available in the modified list." was not found in the text of the element matching css "#drupal-live-announce".

/var/www/html/web/vendor/behat/mink/src/WebAssert.php:847
/var/www/html/web/vendor/behat/mink/src/WebAssert.php:467
/var/www/html/web/core/modules/system/tests/src/FunctionalJavascript/ModuleUninstallFilterTest.php:63
/var/www/html/web/vendor/phpunit/phpunit/src/Framework/TestResult.php:728

Passes with fix.

mgifford’s picture

Issue tags: +wcag327

  • lauriii committed 89eb5575 on 10.1.x
    Issue #2923136 by waako, yogeshmpawar, DamienMcKenna, _utsavsharma,...
lauriii’s picture

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

Opened a follow-up for #17.5.

Committed 89eb557 and pushed to 10.1.x. Thanks!

As a non-disruptive change, this would be qualified for a backport. However, the patch doesn't apply to 10.0.x or 9.5.x so that will require additional patches.

_utsavsharma’s picture

Patch for 9.5.x.

_utsavsharma’s picture

Patch for 10.0.x.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 36: 2923136-36.patch, failed testing. View results

Version: 10.0.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. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.