From 9b49cc3c04295aa19f1d20c43dcaa856b0d4a8be Mon Sep 17 00:00:00 2001
From: Dieter Holvoet <dieter.holvoet@gmail.com>
Date: Tue, 25 Mar 2025 11:15:53 +0100
Subject: [PATCH 1/5] Add rebased changes from previous MR

---
 ...uilderContentModerationIntegrationTest.php |  1 +
 .../menu_ui/config/schema/menu_ui.schema.yml  |  3 +
 core/modules/menu_ui/menu_ui.module           | 11 ++--
 core/modules/menu_ui/src/Hook/MenuUiHooks.php | 12 ++++
 .../MenuUiContentModerationTest.php           |  3 +
 .../tests/src/Functional/MenuUiNodeTest.php   | 57 +++++++++++++++++++
 6 files changed, 83 insertions(+), 4 deletions(-)

diff --git a/core/modules/content_moderation/tests/src/Functional/LayoutBuilderContentModerationIntegrationTest.php b/core/modules/content_moderation/tests/src/Functional/LayoutBuilderContentModerationIntegrationTest.php
index 8d523fa40636..2f2ac1ed5e76 100644
--- a/core/modules/content_moderation/tests/src/Functional/LayoutBuilderContentModerationIntegrationTest.php
+++ b/core/modules/content_moderation/tests/src/Functional/LayoutBuilderContentModerationIntegrationTest.php
@@ -114,6 +114,7 @@ public function testLayoutModeration(): void {
       'title' => 'bar',
       'menu_name' => 'main',
       'description' => 'view bar',
+      'link_enabled' => TRUE,
       'parent' => '',
     ]);
 
diff --git a/core/modules/menu_ui/config/schema/menu_ui.schema.yml b/core/modules/menu_ui/config/schema/menu_ui.schema.yml
index 0ec16221aad4..8a332bb7def0 100644
--- a/core/modules/menu_ui/config/schema/menu_ui.schema.yml
+++ b/core/modules/menu_ui/config/schema/menu_ui.schema.yml
@@ -23,3 +23,6 @@ node.type.*.third_party.menu_ui:
     parent:
       type: string
       label: 'Parent'
+    link_enabled:
+      type: boolean
+      label: 'Enable menu link'
diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module
index cf543258433e..12e0e317a98b 100644
--- a/core/modules/menu_ui/menu_ui.module
+++ b/core/modules/menu_ui/menu_ui.module
@@ -41,8 +41,8 @@ function _menu_ui_node_save(NodeInterface $node, array $values): void {
       'link' => ['uri' => 'entity:node/' . $node->id()],
       'langcode' => $node->language()->getId(),
     ]);
-    $entity->enabled->value = 1;
   }
+  $entity->enabled->value = $values['link_enabled'] ?? 1;
   $entity->title->value = trim($values['title']);
   $entity->description->value = trim($values['description']);
   $entity->menu_name->value = $values['menu_name'];
@@ -130,6 +130,7 @@ function menu_ui_get_menu_link_defaults(NodeInterface $node) {
         'menu_name' => $menu_link->getMenuName(),
         'parent' => $menu_link->getParentId(),
         'weight' => $menu_link->getWeight(),
+        'enabled' => $menu_link->isEnabled(),
       ];
     }
   }
@@ -150,6 +151,7 @@ function menu_ui_get_menu_link_defaults(NodeInterface $node) {
       'menu_name' => $menu_name,
       'parent' => '',
       'weight' => 0,
+      'enabled' => $node_type->getThirdPartySetting('menu_ui', 'link_enabled', (int) !empty($menu_name)),
     ];
   }
   return $defaults;
@@ -165,7 +167,7 @@ function menu_ui_node_builder($entity_type, NodeInterface $entity, &$form, FormS
 /**
  * Form submission handler for menu item field on the node form.
  *
- * @see menu_ui_form_node_form_alter()
+ * @see \Drupal\menu_ui\Hook\MenuUiHooks::formNodeFormAlter()
  */
 function menu_ui_form_node_form_submit($form, FormStateInterface $form_state): void {
   $node = $form_state->getFormObject()->getEntity();
@@ -197,7 +199,7 @@ function menu_ui_form_node_form_submit($form, FormStateInterface $form_state): v
 /**
  * Validate handler for forms with menu options.
  *
- * @see menu_ui_form_node_type_form_alter()
+ * @see \Drupal\menu_ui\Hook\MenuUiHooks::formNodeTypeFormAlter()
  */
 function menu_ui_form_node_type_form_validate(&$form, FormStateInterface $form_state): void {
   $available_menus = array_filter($form_state->getValue('menu_options'));
@@ -217,11 +219,12 @@ function menu_ui_form_node_type_form_validate(&$form, FormStateInterface $form_s
 /**
  * Entity builder for the node type form with menu options.
  *
- * @see menu_ui_form_node_type_form_alter()
+ * @see \Drupal\menu_ui\Hook\MenuUiHooks::formNodeTypeFormAlter()
  */
 function menu_ui_form_node_type_form_builder($entity_type, NodeTypeInterface $type, &$form, FormStateInterface $form_state): void {
   $type->setThirdPartySetting('menu_ui', 'available_menus', array_values(array_filter($form_state->getValue('menu_options'))));
   $type->setThirdPartySetting('menu_ui', 'parent', $form_state->getValue('menu_parent'));
+  $type->setThirdPartySetting('menu_ui', 'link_enabled', $form_state->getValue('link_enabled'));
 }
 
 /**
diff --git a/core/modules/menu_ui/src/Hook/MenuUiHooks.php b/core/modules/menu_ui/src/Hook/MenuUiHooks.php
index ac7c7602f3be..095975d917d2 100644
--- a/core/modules/menu_ui/src/Hook/MenuUiHooks.php
+++ b/core/modules/menu_ui/src/Hook/MenuUiHooks.php
@@ -188,6 +188,13 @@ public function formNodeFormAlter(&$form, FormStateInterface $form_state) : void
       '#default_value' => $defaults['weight'],
       '#description' => $this->t('Menu links with lower weights are displayed before links with higher weights.'),
     ];
+    $form['menu']['link']['link_enabled'] = [
+      '#type' => 'checkbox',
+      '#title' => t('Enabled'),
+      '#description' => t('A flag for whether the link should be visible in menus or hidden.'),
+      '#default_value' => $defaults['enabled'] ?? 1,
+    ];
+
     foreach (array_keys($form['actions']) as $action) {
       if ($action != 'preview' && isset($form['actions'][$action]['#type']) && $form['actions'][$action]['#type'] === 'submit') {
         $form['actions'][$action]['#submit'][] = 'menu_ui_form_node_form_submit';
@@ -253,6 +260,11 @@ public function formNodeTypeFormAlter(&$form, FormStateInterface $form_state) :
       ],
     ];
     $options_cacheability->applyTo($form['menu']['menu_parent']);
+    $form['menu']['link_enabled'] = [
+      '#type' => 'checkbox',
+      '#title' => t('Enable menu link (default)'),
+      '#default_value' => $type->getThirdPartySetting('menu_ui', 'link_enabled', 1),
+    ];
     $form['#validate'][] = 'menu_ui_form_node_type_form_validate';
     $form['#entity_builders'][] = 'menu_ui_form_node_type_form_builder';
   }
diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUiContentModerationTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUiContentModerationTest.php
index 95dc030ba804..10dd17994304 100644
--- a/core/modules/menu_ui/tests/src/Functional/MenuUiContentModerationTest.php
+++ b/core/modules/menu_ui/tests/src/Functional/MenuUiContentModerationTest.php
@@ -86,6 +86,7 @@ public function testMenuUiWithPendingRevisions(): void {
     // Add a menu link and save a new default (published) revision.
     $edit = [
       'menu[enabled]' => 1,
+      'menu[link_enabled]' => 1,
       'menu[title]' => 'Test menu link',
       'moderation_state[0][state]' => 'published',
     ];
@@ -121,6 +122,7 @@ public function testMenuUiWithPendingRevisions(): void {
     // Try to delete the menu link and save a new non-default (draft) revision.
     $edit = [
       'menu[enabled]' => 0,
+      'menu[link_enabled]' => 0,
       'moderation_state[0][state]' => 'draft',
     ];
     $this->drupalGet('node/' . $node->id() . '/edit');
@@ -171,6 +173,7 @@ public function testMenuUiWithPendingRevisions(): void {
     // and ensure it's not immediately published.
     $edit = [
       'menu[enabled]' => 1,
+      'menu[link_enabled]' => 1,
       'menu[title]' => 'Second test menu link',
       'moderation_state[0][state]' => 'draft',
     ];
diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php
index 69b11f376d03..26221e5b63c3 100644
--- a/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php
+++ b/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php
@@ -72,6 +72,35 @@ protected function setUp(): void {
     $this->drupalLogin($this->editor);
   }
 
+  /**
+   * Test correct configuring of default enabling link setting by content type.
+   */
+  public function testContentTypeLinkEnableConfiguration() {
+    // Check that unconfigured content type defaults to enabled links.
+    $this->drupalGet('node/add/page');
+    $this->assertSession()->checkboxChecked('menu[link_enabled]');
+
+    // Configure menu links to be disabled.
+    $edit = [
+      'menu_options[main]' => 1,
+      'menu_parent' => 'main:',
+      'link_enabled' => FALSE,
+    ];
+    $this->drupalGet('admin/structure/types/manage/page');
+    $this->submitForm($edit, 'Save content type');
+    $this->assertSession()->pageTextContains('The content type Basic page has been updated.');
+    $this->drupalGet('node/add/page');
+    $this->assertSession()->checkboxNotChecked('menu[link_enabled]');
+
+    // Configure menu links to be enabled.
+    $edit['link_enabled'] = TRUE;
+    $this->drupalGet('admin/structure/types/manage/page');
+    $this->submitForm($edit, 'Save content type');
+    $this->assertSession()->pageTextContains('The content type Basic page has been updated.');
+    $this->drupalGet('node/add/page');
+    $this->assertSession()->checkboxChecked('menu[link_enabled]');
+  }
+
   /**
    * Tests creating, editing, deleting menu links via node form widget.
    */
@@ -132,6 +161,7 @@ public function testMenuNodeFormWidget(): void {
       'menu_options[main]' => 1,
       'menu_options[tools]' => 1,
       'menu_parent' => 'main:',
+      'link_enabled' => TRUE,
     ];
     $this->drupalGet('admin/structure/types/manage/page');
     $this->submitForm($edit, 'Save');
@@ -142,6 +172,7 @@ public function testMenuNodeFormWidget(): void {
       'title[0][value]' => $node_title,
       'menu[enabled]' => 1,
       'menu[title]' => 'Test preview',
+      'menu[link_enabled]' => 1,
     ];
     $this->drupalGet('node/add/page');
     $this->submitForm($edit, 'Preview');
@@ -185,6 +216,7 @@ public function testMenuNodeFormWidget(): void {
       'menu[enabled]' => 1,
       'menu[title]' => $node_title,
       'status[value]' => FALSE,
+      'menu[link_enabled]' => 1,
     ];
     $this->drupalGet('node/' . $node->id() . '/edit');
     $this->submitForm($edit, 'Save');
@@ -197,13 +229,34 @@ public function testMenuNodeFormWidget(): void {
     $this->drupalGet('test-page');
     $this->assertSession()->linkExists($node_title, 0, 'Found a menu link with the node published');
 
+    // Assert that link is not enabled / does not exist in the rendered menu
+    // if link_enabled option is disabled.
+    $edit['menu[link_enabled]'] = 0;
+    $this->drupalGet('node/' . $node->id() . '/edit');
+    $this->submitForm($edit, 'Save');
+    $this->drupalGet('test-page');
+    $this->assertSession()->linkNotExists($node_title, 'Found no menu link with the node menu link disabled');
+    // If we go to main menu we shall see the disabled menu link.
+    $this->drupalGet('admin/structure/menu/manage/main');
+    $this->assertSession()->checkboxNotChecked("Enable $node_title menu link");
+    // Re-enable link via node form and check menu.
+    $edit['menu[link_enabled]'] = 1;
+    $this->drupalGet('node/' . $node->id() . '/edit');
+    $this->submitForm($edit, 'Save');
+    $this->drupalGet('test-page');
+    // If we go to main menu we shall see the enabled menu link.
+    $this->drupalGet('admin/structure/menu/manage/main');
+    $this->assertSession()->checkboxChecked("Enable $node_title menu link");
+
     // Log back in as normal user.
     $this->drupalLogin($this->editor);
+
     // Edit the node and create a menu link.
     $edit = [
       'menu[enabled]' => 1,
       'menu[title]' => $node_title,
       'menu[weight]' => 17,
+      'menu[link_enabled]' => 1,
     ];
     $this->drupalGet('node/' . $node->id() . '/edit');
     $this->submitForm($edit, 'Save');
@@ -227,6 +280,8 @@ public function testMenuNodeFormWidget(): void {
     $link->set('enabled', FALSE);
     $link->save();
     $this->drupalGet($node->toUrl('edit-form'));
+    // Remove this submission value as it will re-enable menu link on save.
+    unset($edit['menu[link_enabled]']);
     $this->submitForm($edit, 'Save');
     $link = MenuLinkContent::load($link_id);
     $this->assertFalse($link->isEnabled(), 'Saving a node with a disabled menu link keeps the menu link disabled.');
@@ -333,6 +388,7 @@ public function testMultilingualMenuNodeFormWidget(): void {
       'menu[enabled]' => 1,
       'menu[title]' => $node_title,
       'menu[weight]' => 17,
+      'menu[link_enabled]' => 1,
     ];
     $options = ['language' => $languages[$langcodes[0]]];
     $url = $node->toUrl('edit-form', $options);
@@ -344,6 +400,7 @@ public function testMultilingualMenuNodeFormWidget(): void {
       'menu[enabled]' => 1,
       'menu[title]' => $translated_node_title,
       'menu[weight]' => 17,
+      'menu[link_enabled]' => 1,
     ];
     $options = ['language' => $languages[$langcodes[1]]];
     $url = $node->toUrl('edit-form', $options);
-- 
GitLab


From 0b4c0330b1b91261437a8c23eb892f849f363dcf Mon Sep 17 00:00:00 2001
From: Dieter Holvoet <dieter.holvoet@gmail.com>
Date: Tue, 25 Mar 2025 11:23:41 +0100
Subject: [PATCH 2/5] Change integers to booleans

---
 core/modules/menu_ui/menu_ui.module                |  4 ++--
 core/modules/menu_ui/src/Hook/MenuUiHooks.php      |  4 ++--
 .../src/Functional/MenuUiContentModerationTest.php |  6 +++---
 .../tests/src/Functional/MenuUiNodeTest.php        | 14 +++++++-------
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module
index 12e0e317a98b..5b09703f081d 100644
--- a/core/modules/menu_ui/menu_ui.module
+++ b/core/modules/menu_ui/menu_ui.module
@@ -42,7 +42,7 @@ function _menu_ui_node_save(NodeInterface $node, array $values): void {
       'langcode' => $node->language()->getId(),
     ]);
   }
-  $entity->enabled->value = $values['link_enabled'] ?? 1;
+  $entity->enabled->value = $values['link_enabled'] ?? TRUE;
   $entity->title->value = trim($values['title']);
   $entity->description->value = trim($values['description']);
   $entity->menu_name->value = $values['menu_name'];
@@ -151,7 +151,7 @@ function menu_ui_get_menu_link_defaults(NodeInterface $node) {
       'menu_name' => $menu_name,
       'parent' => '',
       'weight' => 0,
-      'enabled' => $node_type->getThirdPartySetting('menu_ui', 'link_enabled', (int) !empty($menu_name)),
+      'enabled' => $node_type->getThirdPartySetting('menu_ui', 'link_enabled', !empty($menu_name)),
     ];
   }
   return $defaults;
diff --git a/core/modules/menu_ui/src/Hook/MenuUiHooks.php b/core/modules/menu_ui/src/Hook/MenuUiHooks.php
index 095975d917d2..fb57304fd685 100644
--- a/core/modules/menu_ui/src/Hook/MenuUiHooks.php
+++ b/core/modules/menu_ui/src/Hook/MenuUiHooks.php
@@ -192,7 +192,7 @@ public function formNodeFormAlter(&$form, FormStateInterface $form_state) : void
       '#type' => 'checkbox',
       '#title' => t('Enabled'),
       '#description' => t('A flag for whether the link should be visible in menus or hidden.'),
-      '#default_value' => $defaults['enabled'] ?? 1,
+      '#default_value' => $defaults['enabled'] ?? TRUE,
     ];
 
     foreach (array_keys($form['actions']) as $action) {
@@ -263,7 +263,7 @@ public function formNodeTypeFormAlter(&$form, FormStateInterface $form_state) :
     $form['menu']['link_enabled'] = [
       '#type' => 'checkbox',
       '#title' => t('Enable menu link (default)'),
-      '#default_value' => $type->getThirdPartySetting('menu_ui', 'link_enabled', 1),
+      '#default_value' => $type->getThirdPartySetting('menu_ui', 'link_enabled', TRUE),
     ];
     $form['#validate'][] = 'menu_ui_form_node_type_form_validate';
     $form['#entity_builders'][] = 'menu_ui_form_node_type_form_builder';
diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUiContentModerationTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUiContentModerationTest.php
index 10dd17994304..96bdff67b7d0 100644
--- a/core/modules/menu_ui/tests/src/Functional/MenuUiContentModerationTest.php
+++ b/core/modules/menu_ui/tests/src/Functional/MenuUiContentModerationTest.php
@@ -86,7 +86,7 @@ public function testMenuUiWithPendingRevisions(): void {
     // Add a menu link and save a new default (published) revision.
     $edit = [
       'menu[enabled]' => 1,
-      'menu[link_enabled]' => 1,
+      'menu[link_enabled]' => TRUE,
       'menu[title]' => 'Test menu link',
       'moderation_state[0][state]' => 'published',
     ];
@@ -122,7 +122,7 @@ public function testMenuUiWithPendingRevisions(): void {
     // Try to delete the menu link and save a new non-default (draft) revision.
     $edit = [
       'menu[enabled]' => 0,
-      'menu[link_enabled]' => 0,
+      'menu[link_enabled]' => FALSE,
       'moderation_state[0][state]' => 'draft',
     ];
     $this->drupalGet('node/' . $node->id() . '/edit');
@@ -173,7 +173,7 @@ public function testMenuUiWithPendingRevisions(): void {
     // and ensure it's not immediately published.
     $edit = [
       'menu[enabled]' => 1,
-      'menu[link_enabled]' => 1,
+      'menu[link_enabled]' => TRUE,
       'menu[title]' => 'Second test menu link',
       'moderation_state[0][state]' => 'draft',
     ];
diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php
index 26221e5b63c3..af9218c6c6fd 100644
--- a/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php
+++ b/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php
@@ -172,7 +172,7 @@ public function testMenuNodeFormWidget(): void {
       'title[0][value]' => $node_title,
       'menu[enabled]' => 1,
       'menu[title]' => 'Test preview',
-      'menu[link_enabled]' => 1,
+      'menu[link_enabled]' => TRUE,
     ];
     $this->drupalGet('node/add/page');
     $this->submitForm($edit, 'Preview');
@@ -216,7 +216,7 @@ public function testMenuNodeFormWidget(): void {
       'menu[enabled]' => 1,
       'menu[title]' => $node_title,
       'status[value]' => FALSE,
-      'menu[link_enabled]' => 1,
+      'menu[link_enabled]' => TRUE,
     ];
     $this->drupalGet('node/' . $node->id() . '/edit');
     $this->submitForm($edit, 'Save');
@@ -231,7 +231,7 @@ public function testMenuNodeFormWidget(): void {
 
     // Assert that link is not enabled / does not exist in the rendered menu
     // if link_enabled option is disabled.
-    $edit['menu[link_enabled]'] = 0;
+    $edit['menu[link_enabled]'] = FALSE;
     $this->drupalGet('node/' . $node->id() . '/edit');
     $this->submitForm($edit, 'Save');
     $this->drupalGet('test-page');
@@ -240,7 +240,7 @@ public function testMenuNodeFormWidget(): void {
     $this->drupalGet('admin/structure/menu/manage/main');
     $this->assertSession()->checkboxNotChecked("Enable $node_title menu link");
     // Re-enable link via node form and check menu.
-    $edit['menu[link_enabled]'] = 1;
+    $edit['menu[link_enabled]'] = TRUE;
     $this->drupalGet('node/' . $node->id() . '/edit');
     $this->submitForm($edit, 'Save');
     $this->drupalGet('test-page');
@@ -256,7 +256,7 @@ public function testMenuNodeFormWidget(): void {
       'menu[enabled]' => 1,
       'menu[title]' => $node_title,
       'menu[weight]' => 17,
-      'menu[link_enabled]' => 1,
+      'menu[link_enabled]' => TRUE,
     ];
     $this->drupalGet('node/' . $node->id() . '/edit');
     $this->submitForm($edit, 'Save');
@@ -388,7 +388,7 @@ public function testMultilingualMenuNodeFormWidget(): void {
       'menu[enabled]' => 1,
       'menu[title]' => $node_title,
       'menu[weight]' => 17,
-      'menu[link_enabled]' => 1,
+      'menu[link_enabled]' => TRUE,
     ];
     $options = ['language' => $languages[$langcodes[0]]];
     $url = $node->toUrl('edit-form', $options);
@@ -400,7 +400,7 @@ public function testMultilingualMenuNodeFormWidget(): void {
       'menu[enabled]' => 1,
       'menu[title]' => $translated_node_title,
       'menu[weight]' => 17,
-      'menu[link_enabled]' => 1,
+      'menu[link_enabled]' => TRUE,
     ];
     $options = ['language' => $languages[$langcodes[1]]];
     $url = $node->toUrl('edit-form', $options);
-- 
GitLab


From a011bfc7bc68945f79493622880fca55fa9136a9 Mon Sep 17 00:00:00 2001
From: Dieter Holvoet <dieter.holvoet@gmail.com>
Date: Tue, 25 Mar 2025 13:28:36 +0100
Subject: [PATCH 3/5] Update description to match the field description

---
 core/modules/menu_ui/src/Hook/MenuUiHooks.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/modules/menu_ui/src/Hook/MenuUiHooks.php b/core/modules/menu_ui/src/Hook/MenuUiHooks.php
index fb57304fd685..482b4a3c3d34 100644
--- a/core/modules/menu_ui/src/Hook/MenuUiHooks.php
+++ b/core/modules/menu_ui/src/Hook/MenuUiHooks.php
@@ -191,7 +191,7 @@ public function formNodeFormAlter(&$form, FormStateInterface $form_state) : void
     $form['menu']['link']['link_enabled'] = [
       '#type' => 'checkbox',
       '#title' => t('Enabled'),
-      '#description' => t('A flag for whether the link should be visible in menus or hidden.'),
+      '#description' => t('A flag for whether the link should be enabled in menus or hidden.'),
       '#default_value' => $defaults['enabled'] ?? TRUE,
     ];
 
-- 
GitLab


From 82df402524676858dcd095bad7ea583d1da5bfbb Mon Sep 17 00:00:00 2001
From: Yaroslav Kozak <y.kozak@dev-branch.com>
Date: Fri, 18 Apr 2025 14:38:20 +0300
Subject: [PATCH 4/5] #3075230 Fixed phpcs, phpstan, spellcheck issues

---
 core/modules/menu_ui/src/Hook/MenuUiHooks.php               | 6 +++---
 .../modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/core/modules/menu_ui/src/Hook/MenuUiHooks.php b/core/modules/menu_ui/src/Hook/MenuUiHooks.php
index ea0dc80f5477..810f8637c92b 100644
--- a/core/modules/menu_ui/src/Hook/MenuUiHooks.php
+++ b/core/modules/menu_ui/src/Hook/MenuUiHooks.php
@@ -224,8 +224,8 @@ public function formNodeFormAlter(&$form, FormStateInterface $form_state) : void
     ];
     $form['menu']['link']['link_enabled'] = [
       '#type' => 'checkbox',
-      '#title' => t('Enabled'),
-      '#description' => t('A flag for whether the link should be enabled in menus or hidden.'),
+      '#title' => $this->t('Enabled'),
+      '#description' => $this->t('A flag for whether the link should be enabled in menus or hidden.'),
       '#default_value' => $defaults['enabled'] ?? TRUE,
     ];
 
@@ -296,7 +296,7 @@ public function formNodeTypeFormAlter(&$form, FormStateInterface $form_state) :
     $options_cacheability->applyTo($form['menu']['menu_parent']);
     $form['menu']['link_enabled'] = [
       '#type' => 'checkbox',
-      '#title' => t('Enable menu link (default)'),
+      '#title' => $this->t('Enable menu link (default)'),
       '#default_value' => $type->getThirdPartySetting('menu_ui', 'link_enabled', TRUE),
     ];
     $form['#validate'][] = 'menu_ui_form_node_type_form_validate';
diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php
index 2136db8f5ff1..4662fba99d79 100644
--- a/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php
+++ b/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php
@@ -75,8 +75,8 @@ protected function setUp(): void {
   /**
    * Test correct configuring of default enabling link setting by content type.
    */
-  public function testContentTypeLinkEnableConfiguration() {
-    // Check that unconfigured content type defaults to enabled links.
+  public function testContentTypeLinkEnableConfiguration(): void {
+    // Check that the non-configured content type defaults to enabled links.
     $this->drupalGet('node/add/page');
     $this->assertSession()->checkboxChecked('menu[link_enabled]');
 
-- 
GitLab


From 0add66ca4baff46bd580376572fbf5de2c0d69aa Mon Sep 17 00:00:00 2001
From: Yaroslav Kozak <y.kozak@dev-branch.com>
Date: Fri, 18 Apr 2025 17:16:04 +0300
Subject: [PATCH 5/5] #3075230 Fixing tests

---
 core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php  | 4 ++--
 core/modules/node/tests/src/Kernel/NodeTypeValidationTest.php | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php
index 4662fba99d79..a160181480cd 100644
--- a/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php
+++ b/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php
@@ -87,7 +87,7 @@ public function testContentTypeLinkEnableConfiguration(): void {
       'link_enabled' => FALSE,
     ];
     $this->drupalGet('admin/structure/types/manage/page');
-    $this->submitForm($edit, 'Save content type');
+    $this->submitForm($edit, 'Save');
     $this->assertSession()->pageTextContains('The content type Basic page has been updated.');
     $this->drupalGet('node/add/page');
     $this->assertSession()->checkboxNotChecked('menu[link_enabled]');
@@ -95,7 +95,7 @@ public function testContentTypeLinkEnableConfiguration(): void {
     // Configure menu links to be enabled.
     $edit['link_enabled'] = TRUE;
     $this->drupalGet('admin/structure/types/manage/page');
-    $this->submitForm($edit, 'Save content type');
+    $this->submitForm($edit, 'Save');
     $this->assertSession()->pageTextContains('The content type Basic page has been updated.');
     $this->drupalGet('node/add/page');
     $this->assertSession()->checkboxChecked('menu[link_enabled]');
diff --git a/core/modules/node/tests/src/Kernel/NodeTypeValidationTest.php b/core/modules/node/tests/src/Kernel/NodeTypeValidationTest.php
index 0761342277a2..1f4ce4f1d333 100644
--- a/core/modules/node/tests/src/Kernel/NodeTypeValidationTest.php
+++ b/core/modules/node/tests/src/Kernel/NodeTypeValidationTest.php
@@ -81,7 +81,7 @@ public function testDescriptionAndHelpCannotBeEmpty(): void {
   }
 
   /**
-   * @testWith [true, {"third_party_settings.menu_ui": "'parent' is a required key."}]
+   * @testWith [true, {"third_party_settings.menu_ui": ["'parent' is a required key.", "'link_enabled' is a required key."]}]
    *           [false, {}]
    */
   public function testThirdPartySettingsMenuUi(bool $third_party_settings_menu_ui_fully_validatable, array $expected_validation_errors): void {
-- 
GitLab