From 9d9877343e31f0019d51d167023078b3ea090596 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Boh=C3=A9mier?=
 <bohemier@1104140.no-reply.drupal.org>
Date: Mon, 20 Jun 2016 09:40:12 -0400
Subject: [PATCH] 2193271-Remove default #size from form elements

---
 core/lib/Drupal/Core/Datetime/Element/Datetime.php                  | 2 --
 core/lib/Drupal/Core/Render/Element/Email.php                       | 1 -
 core/lib/Drupal/Core/Render/Element/File.php                        | 1 -
 core/lib/Drupal/Core/Render/Element/MachineName.php                 | 1 -
 core/lib/Drupal/Core/Render/Element/Password.php                    | 1 -
 core/lib/Drupal/Core/Render/Element/Search.php                      | 1 -
 core/lib/Drupal/Core/Render/Element/Tel.php                         | 1 -
 core/lib/Drupal/Core/Render/Element/Textfield.php                   | 1 -
 core/lib/Drupal/Core/Render/Element/Url.php                         | 1 -
 core/lib/Drupal/Core/Render/Element/Weight.php                      | 2 --
 core/modules/system/tests/themes/test_theme/test_theme.theme        | 6 +++---
 .../Drupal/KernelTests/Core/Render/ElementInfoIntegrationTest.php   | 4 ++--
 12 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/core/lib/Drupal/Core/Datetime/Element/Datetime.php b/core/lib/Drupal/Core/Datetime/Element/Datetime.php
index 44a3949..eb150ee 100644
--- a/core/lib/Drupal/Core/Datetime/Element/Datetime.php
+++ b/core/lib/Drupal/Core/Datetime/Element/Datetime.php
@@ -261,7 +261,6 @@ public static function processDatetime(&$element, FormStateInterface $form_state
         '#value' => $date_value,
         '#attributes' => $element['#attributes'] + $extra_attributes,
         '#required' => $element['#required'],
-        '#size' => max(12, strlen($element['#value']['date'])),
         '#error_no_message' => TRUE,
         '#date_date_format' => $element['#date_date_format'],
       );
@@ -294,7 +293,6 @@ public static function processDatetime(&$element, FormStateInterface $form_state
         '#value' => $time_value,
         '#attributes' => $element['#attributes'] + $extra_attributes,
         '#required' => $element['#required'],
-        '#size' => 12,
         '#error_no_message' => TRUE,
       );
 
diff --git a/core/lib/Drupal/Core/Render/Element/Email.php b/core/lib/Drupal/Core/Render/Element/Email.php
index 4b4da7b..de612ef 100644
--- a/core/lib/Drupal/Core/Render/Element/Email.php
+++ b/core/lib/Drupal/Core/Render/Element/Email.php
@@ -44,7 +44,6 @@ public function getInfo() {
     $class = get_class($this);
     return array(
       '#input' => TRUE,
-      '#size' => 60,
       '#maxlength' => self::EMAIL_MAX_LENGTH,
       '#autocomplete_route_name' => FALSE,
       '#process' => array(
diff --git a/core/lib/Drupal/Core/Render/Element/File.php b/core/lib/Drupal/Core/Render/Element/File.php
index d37d5c7..9a173d2 100644
--- a/core/lib/Drupal/Core/Render/Element/File.php
+++ b/core/lib/Drupal/Core/Render/Element/File.php
@@ -30,7 +30,6 @@ public function getInfo() {
       '#process' => array(
         array($class, 'processFile'),
       ),
-      '#size' => 60,
       '#pre_render' => array(
         array($class, 'preRenderFile'),
       ),
diff --git a/core/lib/Drupal/Core/Render/Element/MachineName.php b/core/lib/Drupal/Core/Render/Element/MachineName.php
index c92d0e0..0827c04 100644
--- a/core/lib/Drupal/Core/Render/Element/MachineName.php
+++ b/core/lib/Drupal/Core/Render/Element/MachineName.php
@@ -80,7 +80,6 @@ public function getInfo() {
       '#default_value' => NULL,
       '#required' => TRUE,
       '#maxlength' => 64,
-      '#size' => 60,
       '#autocomplete_route_name' => FALSE,
       '#process' => array(
         array($class, 'processMachineName'),
diff --git a/core/lib/Drupal/Core/Render/Element/Password.php b/core/lib/Drupal/Core/Render/Element/Password.php
index e16e8bb..431fd0b 100644
--- a/core/lib/Drupal/Core/Render/Element/Password.php
+++ b/core/lib/Drupal/Core/Render/Element/Password.php
@@ -31,7 +31,6 @@ public function getInfo() {
     $class = get_class($this);
     return array(
       '#input' => TRUE,
-      '#size' => 60,
       '#maxlength' => 128,
       '#process' => array(
         array($class, 'processAjaxForm'),
diff --git a/core/lib/Drupal/Core/Render/Element/Search.php b/core/lib/Drupal/Core/Render/Element/Search.php
index 45333c5..69802adb 100644
--- a/core/lib/Drupal/Core/Render/Element/Search.php
+++ b/core/lib/Drupal/Core/Render/Element/Search.php
@@ -28,7 +28,6 @@ public function getInfo() {
     $class = get_class($this);
     return array(
       '#input' => TRUE,
-      '#size' => 60,
       '#maxlength' => 128,
       '#autocomplete_route_name' => FALSE,
       '#process' => array(
diff --git a/core/lib/Drupal/Core/Render/Element/Tel.php b/core/lib/Drupal/Core/Render/Element/Tel.php
index 02b071d..c678d2b 100644
--- a/core/lib/Drupal/Core/Render/Element/Tel.php
+++ b/core/lib/Drupal/Core/Render/Element/Tel.php
@@ -31,7 +31,6 @@ public function getInfo() {
     $class = get_class($this);
     return array(
       '#input' => TRUE,
-      '#size' => 30,
       '#maxlength' => 128,
       '#autocomplete_route_name' => FALSE,
       '#process' => array(
diff --git a/core/lib/Drupal/Core/Render/Element/Textfield.php b/core/lib/Drupal/Core/Render/Element/Textfield.php
index 1cb35e8..ee87b1f 100644
--- a/core/lib/Drupal/Core/Render/Element/Textfield.php
+++ b/core/lib/Drupal/Core/Render/Element/Textfield.php
@@ -49,7 +49,6 @@ public function getInfo() {
     $class = get_class($this);
     return array(
       '#input' => TRUE,
-      '#size' => 60,
       '#maxlength' => 128,
       '#autocomplete_route_name' => FALSE,
       '#process' => array(
diff --git a/core/lib/Drupal/Core/Render/Element/Url.php b/core/lib/Drupal/Core/Render/Element/Url.php
index 33d91ed..83c438f 100644
--- a/core/lib/Drupal/Core/Render/Element/Url.php
+++ b/core/lib/Drupal/Core/Render/Element/Url.php
@@ -35,7 +35,6 @@ public function getInfo() {
     $class = get_class($this);
     return array(
       '#input' => TRUE,
-      '#size' => 60,
       '#maxlength' => 255,
       '#autocomplete_route_name' => FALSE,
       '#process' => array(
diff --git a/core/lib/Drupal/Core/Render/Element/Weight.php b/core/lib/Drupal/Core/Render/Element/Weight.php
index a6ecbee..bd22e07 100644
--- a/core/lib/Drupal/Core/Render/Element/Weight.php
+++ b/core/lib/Drupal/Core/Render/Element/Weight.php
@@ -65,8 +65,6 @@ public static function processWeight(&$element, FormStateInterface $form_state,
     // Otherwise, use a text field.
     else {
       $element['#type'] = 'number';
-      // Use a field big enough to fit most weights.
-      $element['#size'] = 10;
       $element += $element_info_manager->getInfo('number');
     }
 
diff --git a/core/modules/system/tests/themes/test_theme/test_theme.theme b/core/modules/system/tests/themes/test_theme/test_theme.theme
index aa399b6..1745839 100644
--- a/core/modules/system/tests/themes/test_theme/test_theme.theme
+++ b/core/modules/system/tests/themes/test_theme/test_theme.theme
@@ -23,9 +23,9 @@ function test_theme_theme_test__suggestion($variables) {
  * Implements hook_element_info_alter().
  */
 function test_theme_element_info_alter(&$info) {
-  // Decrease the default size of textfields.
-  if (isset($info['textfield']['#size'])) {
-    $info['textfield']['#size'] = 40;
+  // Decrease the default maxlength of textfields.
+  if (isset($info['textfield']['#maxlength'])) {
+    $info['textfield']['#maxlength'] = 100;
   }
 }
 
diff --git a/core/tests/Drupal/KernelTests/Core/Render/ElementInfoIntegrationTest.php b/core/tests/Drupal/KernelTests/Core/Render/ElementInfoIntegrationTest.php
index cd33fcb..5ff30be 100644
--- a/core/tests/Drupal/KernelTests/Core/Render/ElementInfoIntegrationTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Render/ElementInfoIntegrationTest.php
@@ -34,10 +34,10 @@ public function testElementInfoByTheme() {
     $element_info = $this->container->get('plugin.manager.element_info');
 
     $theme_manager->setActiveTheme($theme_initializer->getActiveThemeByName('classy'));
-    $this->assertEqual(60, $element_info->getInfo('textfield')['#size']);
+    $this->assertEqual(128, $element_info->getInfo('textfield')['#maxlength']);
 
     $theme_manager->setActiveTheme($theme_initializer->getActiveThemeByName('test_theme'));
-    $this->assertEqual(40, $element_info->getInfo('textfield')['#size']);
+    $this->assertEqual(100, $element_info->getInfo('textfield')['#maxlength']);
   }
 
 }
-- 
2.7.4 (Apple Git-66)

