Problem/Motivation

v2 of the module supports the ability to overwrite settings for a menu at the block-level. This comes with the caveat that this only works outside of Layout Builder.

This was originally discussed here: https://www.drupal.org/project/accessible_menu/issues/3539636

Using form alters, there doesn't seem to be a way to get the menu's machine name- or even tell if the block your editing is a menu block- in the side tray. I took a look at how the Menu Block module does it, and they actually make an entirely new block type and then hide the system menu blocks so you can't use them anymore. I don't really want to do this- it seems problematic.

I would like to not do what Menu Block does if possible because it seems like it would become problematic if someone were to uninstall Accessible Menu (the block would break).

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

nickdjm created an issue. See original summary.

nickolaj made their first commit to this issue’s fork.

nickolaj’s picture

Status: Active » Needs review

Added Layout Builder support for block-level Accessible Menu settings. Uses `hook_form_layout_builder_update_block_alter()` and `hook_form_layout_builder_add_block_alter()` to detect menu blocks in the side tray, extracting the menu machine name from the block plugin ID and using the section component UUID for block-level config storage. Also updates `preprocess_block` and `theme_suggestions_block_alter` to resolve Layout Builder component UUIDs when `#id` is NULL.

nickdjm’s picture

So idk if I'm missing something, but this doesn't seem to work.

When using this MR, I get the following error when trying to configure a menu block:

NOTICE: PHP message: Uncaught PHP Exception Error: "Call to undefined method Drupal\layout_builder\Form\UpdateBlockForm::getCurrentBlock()" at /var/www/html/web/modules/contrib/accessible_menu/accessible_menu.module line 137

I don't see this method anywhere in the code-base, nor is it in the api docs. Where did it come from?

nickdjm’s picture

Status: Needs review » Needs work
nickdjm’s picture

I suspect this initial attempt was AI-generated if I'm being honest. The fact that @nickolaj's account also appears to be deleted and 403ing now also seems suspicious.

I'm carrying forward with some changes to v2 that should help with this.

I am converting all config to third party settings- the reason for doing this is 2-fold:

  1. It really should have been the way to begin with, and
  2. there might be some hope for third party settings being supported out of the box in layout builder components (https://www.drupal.org/project/drupal/issues/3015152)

This isn't to say I'm going to implement 3rd party settings and then wait for layout builder- I still plan on looking into this, but at least there may be some hope to remove extra code in the future.

nickdjm changed the visibility of the branch 3572043-allow-block-level-settings to hidden.

nickdjm’s picture

Ok, well I've figured it out.

ThirdPartySettings would be a nice-to-have, but we can get this to work without it.

All that's left is to make sure uninstalling cleans things up nicely (which is _why_ ThirdPartySettings would be nice).

nickdjm’s picture

Version: 2.x-dev » 2.0.0-beta3
Status: Needs work » Fixed

I have a working version out in 2.0.0-beta3.

Once there's been a bit more testing, then I think we're ready for a full release of 2.0.0

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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