Problem/Motivation

Trying to change the "Maximum number of menu levels to display" does not work anymore, it's always 1 no matter what I try to set this to.

To clarify:

1) I configure a menu block (in this case the Main Menu)
2) Change the max levels to display to something other than 1, e.g. 3
3) Save the block

No change in the site, expanded menus are not printed in the output.
Go back and check the config, appears my selection of "3" has not been saved, the value is still 1.

Proposed resolution

Remaining tasks

User interface changes

API changes

Comments

Jeff Burnz’s picture

Issue summary: View changes
swentel’s picture

Title: Menu block "Maximum number of menu levels to display" always 1 » Menu block - menu level and depth are not saved
Component: block.module » system.module
StatusFileSize
new828 bytes
swentel’s picture

Status: Active » Needs review
joachim’s picture

Status: Needs review » Reviewed & tested by the community

Confirming the bug and the fix.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Looks like we need a test here - no?

alexpott’s picture

Priority: Major » Critical

Also this feels like a critical piece of functionality is not working.

larowlan’s picture

Assigned: Unassigned » larowlan

Working on tests

larowlan’s picture

Assigned: larowlan » Unassigned
Issue tags: -Needs tests
StatusFileSize
new1.59 KB
new2.4 KB

hoping for red/green

larowlan’s picture

Status: Needs work » Needs review

The last submitted patch, 8: menu-lvls-tst-2384653.fail_.patch, failed testing.

jibran’s picture

+++ b/core/modules/menu_ui/src/Tests/MenuTest.php
@@ -867,4 +876,18 @@ private function verifyAccess($response = 200) {
+    $this->assertFieldByName('settings[depth]', 3);

We are only checking depth can we add level assert as well?

larowlan’s picture

StatusFileSize
new668 bytes
new2.48 KB

sure

jibran’s picture

Status: Needs review » Reviewed & tested by the community

Thanks.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 12: menu-lvls-tst-2384653.2.patch, failed testing.

jibran’s picture

+++ b/core/modules/menu_ui/src/Tests/MenuTest.php
@@ -867,4 +876,20 @@ private function verifyAccess($response = 200) {
+      'settings[level]' => 2,
...
+    $this->assertFieldByName('settings[level]', 2);

I think this broke the other test :)

larowlan’s picture

Status: Needs work » Needs review
StatusFileSize
new780 bytes
new2.63 KB

ya

Status: Needs review » Needs work

The last submitted patch, 16: menu-lvls-tst-2384653.3.patch, failed testing.

larowlan’s picture

Status: Needs work » Needs review
StatusFileSize
new528 bytes
new2.63 KB

take 4

jibran’s picture

+++ b/core/modules/menu_ui/src/Tests/MenuTest.php
@@ -867,4 +876,25 @@ private function verifyAccess($response = 200) {
+      'settings[depth]' => 0,
+      'settings[level]' => 1,

Can't we do it on first attempt and check the values? I think default values are 1 for both depth and level.

larowlan’s picture

The values in the final submit are the defaults.
So we need to submit something else to test it saves.

dawehner’s picture

+++ b/core/modules/menu_ui/src/Tests/MenuTest.php
@@ -867,4 +876,25 @@ private function verifyAccess($response = 200) {
+    $this->assertFieldByName('settings[depth]', 3);
+    $this->assertFieldByName('settings[level]', 2);
+    // Reset settings.
+    $this->drupalPostForm(NULL, [
+      'settings[depth]' => 0,
+      'settings[level]' => 1,
+    ], t('Save block'));
+  }

So what about looking at the final configuration entity in order to see whether things got saved?

larowlan’s picture

So what about looking at the final configuration entity in order to see whether things got saved?

Block->settings is protected so we can't

dawehner’s picture

But there is:

ConfigEntityBase::get()

as well as

$block->getPlugin()->getConfiguration()

larowlan’s picture

StatusFileSize
new1.21 KB
new2.85 KB

like so?

dawehner’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Quickfix

+1

Let's be honest this critical is kinda a quickfix.

jibran’s picture

Last interdiff is a delight thanks @dawehner for the suggestion @larowlan++
+1 RTBC.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.0.x, thanks!

  • catch committed 7854cac on 8.0.x
    Issue #2384653 by larowlan, swentel: Menu block - menu level and depth...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.