From f6d07a146ea18e994f35d7fc57b34c63c4215a36 Mon Sep 17 00:00:00 2001
From: nod_ <nod_@598310.no-reply.drupal.org>
Date: Fri, 21 Mar 2025 10:05:49 +0100
Subject: [PATCH] Issue #3512194 by catch, smustgrave, nod_: Move resize CSS
 into its own library

---
 core/core.libraries.yml                           | 15 +++++++++++++++
 core/lib/Drupal/Core/Render/Element/Textarea.php  |  9 +++++++++
 .../css => misc}/components/resize.module.css     |  0
 .../src/FunctionalJavascript/PerformanceTest.php  |  2 +-
 core/modules/system/system.libraries.yml          |  1 -
 .../AssetAggregationAcrossPagesTest.php           |  2 +-
 .../StandardPerformanceTest.php                   |  6 +++---
 .../{system => core}/components/resize.module.css |  0
 core/themes/stable9/stable9.info.yml              |  6 +++++-
 9 files changed, 34 insertions(+), 7 deletions(-)
 rename core/{modules/system/css => misc}/components/resize.module.css (100%)
 rename core/themes/stable9/css/{system => core}/components/resize.module.css (100%)

diff --git a/core/core.libraries.yml b/core/core.libraries.yml
index 770bcf7c9ec9..60261676fa0e 100644
--- a/core/core.libraries.yml
+++ b/core/core.libraries.yml
@@ -647,6 +647,21 @@ drupal.progress:
     - core/jquery
     - core/drupalSettings
 
+drupal.textarea-resize:
+  version: VERSION
+  css:
+    component:
+      misc/components/resize.module.css: { weight: -10 }
+  moved_files:
+    system/base:
+      deprecation_version: 11.2.0
+      removed_version: 12.0.0
+      deprecation_link: https://www.drupal.org/node/3432346
+      css:
+        component:
+          css/components/resize.module.css:
+            component: misc/components/resize.module.css
+
 drupal.states:
   version: VERSION
   js:
diff --git a/core/lib/Drupal/Core/Render/Element/Textarea.php b/core/lib/Drupal/Core/Render/Element/Textarea.php
index e071c76c97c7..c3fc60219244 100644
--- a/core/lib/Drupal/Core/Render/Element/Textarea.php
+++ b/core/lib/Drupal/Core/Render/Element/Textarea.php
@@ -44,12 +44,21 @@ public function getInfo() {
       ],
       '#pre_render' => [
         [static::class, 'preRenderGroup'],
+        [static::class, 'preRenderAttachments'],
       ],
       '#theme' => 'textarea',
       '#theme_wrappers' => ['form_element'],
     ];
   }
 
+  /**
+   * Adds the textarea resize library.
+   */
+  public static function preRenderAttachments($element): array {
+    $element['#attached']['library'][] = 'core/drupal.textarea-resize';
+    return $element;
+  }
+
   /**
    * {@inheritdoc}
    */
diff --git a/core/modules/system/css/components/resize.module.css b/core/misc/components/resize.module.css
similarity index 100%
rename from core/modules/system/css/components/resize.module.css
rename to core/misc/components/resize.module.css
diff --git a/core/modules/navigation/tests/src/FunctionalJavascript/PerformanceTest.php b/core/modules/navigation/tests/src/FunctionalJavascript/PerformanceTest.php
index 7b50dbd0da79..f447a9aa3aae 100644
--- a/core/modules/navigation/tests/src/FunctionalJavascript/PerformanceTest.php
+++ b/core/modules/navigation/tests/src/FunctionalJavascript/PerformanceTest.php
@@ -93,7 +93,7 @@ public function testLogin(): void {
       'ScriptCount' => 3,
       'ScriptBytes' => 215500,
       'StylesheetCount' => 1,
-      'StylesheetBytes' => 46300,
+      'StylesheetBytes' => 46000,
     ];
     $this->assertMetrics($expected, $performance_data);
 
diff --git a/core/modules/system/system.libraries.yml b/core/modules/system/system.libraries.yml
index 12017369189e..19e3935aa388 100644
--- a/core/modules/system/system.libraries.yml
+++ b/core/modules/system/system.libraries.yml
@@ -13,7 +13,6 @@ base:
       css/components/nowrap.module.css: { weight: -10 }
       css/components/position-container.module.css: { weight: -10 }
       css/components/reset-appearance.module.css: { weight: -10 }
-      css/components/resize.module.css: { weight: -10 }
       css/components/tablesort.module.css: { weight: -10 }
 
 admin:
diff --git a/core/profiles/demo_umami/tests/src/FunctionalJavascript/AssetAggregationAcrossPagesTest.php b/core/profiles/demo_umami/tests/src/FunctionalJavascript/AssetAggregationAcrossPagesTest.php
index 0eeb6a82fb55..270848ef1500 100644
--- a/core/profiles/demo_umami/tests/src/FunctionalJavascript/AssetAggregationAcrossPagesTest.php
+++ b/core/profiles/demo_umami/tests/src/FunctionalJavascript/AssetAggregationAcrossPagesTest.php
@@ -30,7 +30,7 @@ public function testFrontAndRecipesPages(): void {
       'ScriptCount' => 1,
       'ScriptBytes' => 11700,
       'StylesheetCount' => 6,
-      'StylesheetBytes' => 121000,
+      'StylesheetBytes' => 120500,
     ];
     $this->assertMetrics($expected, $performance_data);
   }
diff --git a/core/profiles/standard/tests/src/FunctionalJavascript/StandardPerformanceTest.php b/core/profiles/standard/tests/src/FunctionalJavascript/StandardPerformanceTest.php
index 5a797ad874b3..aa8d6dca9bb0 100644
--- a/core/profiles/standard/tests/src/FunctionalJavascript/StandardPerformanceTest.php
+++ b/core/profiles/standard/tests/src/FunctionalJavascript/StandardPerformanceTest.php
@@ -191,7 +191,7 @@ protected function testAnonymous(): void {
         ['config:user.role.anonymous'],
       ],
       'StylesheetCount' => 1,
-      'StylesheetBytes' => 2250,
+      'StylesheetBytes' => 2100,
     ];
     $this->assertMetrics($expected, $performance_data);
     $expected_default_cache_cids = [
@@ -275,7 +275,7 @@ protected function testAnonymous(): void {
         ['config:user.role.anonymous'],
       ],
       'StylesheetCount' => 1,
-      'StylesheetBytes' => 2250,
+      'StylesheetBytes' => 2100,
     ];
     $this->assertMetrics($expected, $performance_data);
 
@@ -312,7 +312,7 @@ protected function testAnonymous(): void {
       'CacheTagInvalidationCount' => 0,
       'CacheTagLookupQueryCount' => 13,
       'StylesheetCount' => 1,
-      'StylesheetBytes' => 1950,
+      'StylesheetBytes' => 1800,
     ];
     $this->assertMetrics($expected, $performance_data);
   }
diff --git a/core/themes/stable9/css/system/components/resize.module.css b/core/themes/stable9/css/core/components/resize.module.css
similarity index 100%
rename from core/themes/stable9/css/system/components/resize.module.css
rename to core/themes/stable9/css/core/components/resize.module.css
diff --git a/core/themes/stable9/stable9.info.yml b/core/themes/stable9/stable9.info.yml
index a8fb889436a9..70ac743dbd5b 100644
--- a/core/themes/stable9/stable9.info.yml
+++ b/core/themes/stable9/stable9.info.yml
@@ -78,6 +78,11 @@ libraries-override:
       component:
         misc/components/progress.module.css: css/core/components/progress.module.css
 
+  core/drupal.textarea-resize:
+    css:
+      component:
+        misc/components/resize.module.css: css/core/components/resize.module.css
+
   core/drupal.tabledrag:
     css:
       component:
@@ -234,7 +239,6 @@ libraries-override:
         css/components/nowrap.module.css: css/system/components/nowrap.module.css
         css/components/position-container.module.css: css/system/components/position-container.module.css
         css/components/reset-appearance.module.css: css/system/components/reset-appearance.module.css
-        css/components/resize.module.css: css/system/components/resize.module.css
         css/components/tablesort.module.css: css/system/components/tablesort.module.css
   system/admin:
     css:
-- 
GitLab