diff --git a/core/misc/tableselect.js b/core/misc/tableselect.js
index 243e000..f97bc56 100644
--- a/core/misc/tableselect.js
+++ b/core/misc/tableselect.js
@@ -17,8 +17,11 @@
    */
   Drupal.behaviors.tableSelect = {
     attach: function (context, settings) {
-      // Select the inner-most table in case of nested tables.
-      $(context).find('th.select-all').closest('table').once('table-select').each(Drupal.tableSelect);
+      // Select the inner-most table in case of nested tables. Append tables
+      // with attribute 'data-drupal-select-all' to collection.
+      $(context).find('th.select-all').closest('table')
+        .add('[data-drupal-select-all]')
+        .once('table-select').each(Drupal.tableSelect);
     }
   };
 
@@ -92,11 +95,6 @@
       // Either add or remove the selected class based on the state of the
       // check all checkbox.
 
-      /**
-       * @this {HTMLElement}
-       */
-      $(this).closest('tr').toggleClass('selected', this.checked);
-
       // If this is a shift click, we need to highlight everything in the
       // range. Also make sure that we are actually checking checkboxes
       // over a range and that a checkbox has been checked or unchecked before.
@@ -133,15 +131,20 @@
     // Traverse through the sibling nodes.
     for (var i = from[mode]; i; i = i[mode]) {
       var $i;
+      var $checkbox;
       // Make sure that we're only dealing with elements.
       if (i.nodeType !== 1) {
         continue;
       }
       $i = $(i);
+      $checkbox = $i.find('input[type="checkbox"]');
+      // Skip disabled elements for visual coherence.
+      if ($checkbox.prop('disabled')) {
+        continue;
+      }
       // Either add or remove the selected class based on the state of the
       // target checkbox.
-      $i.toggleClass('selected', state);
-      $i.find('input[type="checkbox"]').prop('checked', state);
+      $checkbox.prop('checked', state);
 
       if (to.nodeType) {
         // If we are at the end of the range, stop.
diff --git a/core/modules/system/src/Form/ModulesListForm.php b/core/modules/system/src/Form/ModulesListForm.php
index 28ff7ef..e2aa121 100644
--- a/core/modules/system/src/Form/ModulesListForm.php
+++ b/core/modules/system/src/Form/ModulesListForm.php
@@ -176,6 +176,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
     // Lastly, sort all packages by title.
     uasort($form['modules'], ['\Drupal\Component\Utility\SortArray', 'sortByTitleProperty']);
 
+    $form['#attached']['library'][] = 'core/drupal.tableselect';
     $form['#attached']['library'][] = 'system/drupal.system.modules';
     $form['actions'] = ['#type' => 'actions'];
     $form['actions']['submit'] = [
diff --git a/core/modules/system/src/Form/ModulesUninstallForm.php b/core/modules/system/src/Form/ModulesUninstallForm.php
index 80348c5..c756d59 100644
--- a/core/modules/system/src/Form/ModulesUninstallForm.php
+++ b/core/modules/system/src/Form/ModulesUninstallForm.php
@@ -151,6 +151,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
       }
     }
 
+    $form['#attached']['library'][] = 'core/drupal.tableselect';
     $form['#attached']['library'][] = 'system/drupal.system.modules';
     $form['actions'] = ['#type' => 'actions'];
     $form['actions']['submit'] = [
diff --git a/core/modules/system/templates/system-modules-details.html.twig b/core/modules/system/templates/system-modules-details.html.twig
index e431c8e..754d2dc 100644
--- a/core/modules/system/templates/system-modules-details.html.twig
+++ b/core/modules/system/templates/system-modules-details.html.twig
@@ -24,7 +24,7 @@
  * @ingroup themeable
  */
 #}
-<table class="responsive-enabled" data-striping="1">
+<table class="responsive-enabled" data-striping="1" data-drupal-select-all="1">
   <thead>
     <tr>
       <th class="checkbox visually-hidden">{{ 'Installed'|t }}</th>
diff --git a/core/modules/system/templates/system-modules-uninstall.html.twig b/core/modules/system/templates/system-modules-uninstall.html.twig
index 180ca08..1c0dd74 100644
--- a/core/modules/system/templates/system-modules-uninstall.html.twig
+++ b/core/modules/system/templates/system-modules-uninstall.html.twig
@@ -23,7 +23,7 @@
 #}
 {{ form.filters }}
 
-<table class="responsive-enabled" data-striping="1">
+<table class="responsive-enabled" data-striping="1" data-drupal-select-all="1">
   <thead>
     <tr>
       <th>{{ 'Uninstall'|t }}</th>
diff --git a/core/themes/stable/templates/admin/system-modules-details.html.twig b/core/themes/stable/templates/admin/system-modules-details.html.twig
index 618b58a..35397a5 100644
--- a/core/themes/stable/templates/admin/system-modules-details.html.twig
+++ b/core/themes/stable/templates/admin/system-modules-details.html.twig
@@ -22,7 +22,7 @@
  * @see template_preprocess_system_modules_details()
  */
 #}
-<table class="responsive-enabled" data-striping="1">
+<table class="responsive-enabled" data-striping="1" data-drupal-select-all="1">
   <thead>
     <tr>
       <th class="checkbox visually-hidden">{{ 'Installed'|t }}</th>
diff --git a/core/themes/stable/templates/admin/system-modules-uninstall.html.twig b/core/themes/stable/templates/admin/system-modules-uninstall.html.twig
index 3556709..37675b6 100644
--- a/core/themes/stable/templates/admin/system-modules-uninstall.html.twig
+++ b/core/themes/stable/templates/admin/system-modules-uninstall.html.twig
@@ -21,7 +21,7 @@
 #}
 {{ form.filters }}
 
-<table class="responsive-enabled" data-striping="1">
+<table class="responsive-enabled" data-striping="1" data-drupal-select-all="1">
   <thead>
     <tr>
       <th>{{ 'Uninstall'|t }}</th>
