From de5d27e6eff7a3ed4e50a0e9a5fc1c598b0c1c79 Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Tue, 17 Feb 2015 00:32:32 +0000
Subject: [PATCH] Issue #2427161 by tstoeckler: shortcut.admin.js broken,
 replace with #states

---
 core/modules/shortcut/shortcut.admin.js        | 18 ------------------
 core/modules/shortcut/shortcut.libraries.yml   |  8 --------
 .../shortcut/src/Form/SwitchShortcutSet.php    | 10 +++++-----
 3 files changed, 5 insertions(+), 31 deletions(-)
 delete mode 100644 core/modules/shortcut/shortcut.admin.js

diff --git a/core/modules/shortcut/shortcut.admin.js b/core/modules/shortcut/shortcut.admin.js
deleted file mode 100644
index 7fbdc5cec34b..000000000000
--- a/core/modules/shortcut/shortcut.admin.js
+++ /dev/null
@@ -1,18 +0,0 @@
-(function ($) {
-
-  "use strict";
-
-  /**
-   * Make it so when you enter text into the "New set" textfield, the
-   * corresponding radio button gets selected.
-   */
-  Drupal.behaviors.newSet = {
-    attach: function (context, settings) {
-      var selectDefault = function () {
-        $(this).closest('form').find('.form-item-set .form-type-radio:last input').prop('checked', true);
-      };
-      $('div.form-item-new input').on('focus', selectDefault).on('keyup', selectDefault);
-    }
-  };
-
-})(jQuery);
diff --git a/core/modules/shortcut/shortcut.libraries.yml b/core/modules/shortcut/shortcut.libraries.yml
index 25f630d7f0e4..90152dad4e45 100644
--- a/core/modules/shortcut/shortcut.libraries.yml
+++ b/core/modules/shortcut/shortcut.libraries.yml
@@ -1,11 +1,3 @@
-drupal.shortcut.admin:
-  version: VERSION
-  js:
-    shortcut.admin.js: {}
-  dependencies:
-    - core/jquery
-    - core/drupal
-
 drupal.shortcut:
   version: VERSION
   css:
diff --git a/core/modules/shortcut/src/Form/SwitchShortcutSet.php b/core/modules/shortcut/src/Form/SwitchShortcutSet.php
index 496fa0765eff..897399714f53 100644
--- a/core/modules/shortcut/src/Form/SwitchShortcutSet.php
+++ b/core/modules/shortcut/src/Form/SwitchShortcutSet.php
@@ -105,9 +105,13 @@ public function buildForm(array $form, FormStateInterface $form_state, UserInter
       $form['label'] = array(
         '#type' => 'textfield',
         '#title' => $this->t('Label'),
-        '#title_display' => 'invisible',
         '#description' => $this->t('The new set is created by copying items from your default shortcut set.'),
         '#access' => $add_access,
+        '#states' => array(
+          'visible' => array(
+            ':input[name="set"]' => array('value' => 'new'),
+          ),
+        ),
       );
       $form['id'] = array(
         '#type' => 'machine_name',
@@ -131,10 +135,6 @@ public function buildForm(array $form, FormStateInterface $form_state, UserInter
         $form['new']['#description'] = $this->t('The new set is created by copying items from the %default set.', array('%default' => $default_set->label()));
       }
 
-      $form['#attached'] = array(
-        'library' => array('shortcut/drupal.shortcut.admin'),
-      );
-
       $form['actions'] = array('#type' => 'actions');
       $form['actions']['submit'] = array(
         '#type' => 'submit',
-- 
GitLab