Problem/Motivation
The menu component (components/menu/menu.twig, line 10) calls drupal_menu(). This Twig function comes from the Twig Tweak module. Twig Tweak is not listed in composer.json or sdc_components.info.yml.

On a site without Twig Tweak, any page that renders the menu component fails with:
Twig\Error\SyntaxError: Unknown "drupal_menu" function in "sdc_components:menu" at line 10.

Steps to reproduce
1. Install SDC Components 2.x on a site without Twig Tweak.
2. Install UI Patterns 2.x with UI Patterns Library.
3. Visit /admin/appearance/ui/components/sdc_components/menu.
4. The page shows "The website encountered an unexpected error".

After enabling Twig Tweak, the page loads.

Found while testing #3639558.

Proposed resolution
Add Twig Tweak as a dependency in composer.json and sdc_components.info.yml.

AI disclosure: I used Claude Code to help find the cause and draft this issue. I reproduced the error myself on Drupal 11.4.11.

Menu component page without Twig Tweak, showing "The website encountered an unexpected error"

Comments

anshika agrawal created an issue. See original summary.

flyke’s picture

Status: Active » Needs review

This was the only component that seemed to depend on the twig_tweak module. So I created a custom menu render twig extension and use that, so there is no dependency needed on the twig_tweak module.
Please test if issue is fixed in the latest dev version.

flyke’s picture

Status: Needs review » Reviewed & tested by the community
anshika agrawal’s picture

StatusFileSize
new303.31 KB

I tested the latest 2.x-dev (commit 14ce9aa, which includes the fix in 00d6421) on Drupal 11.4.11.

Steps:
1. Pulled the latest 2.x.
2. Uninstalled Twig Tweak and cleared the cache.
3. Opened /admin/appearance/ui/components/sdc_components/menu.

Result: the page loads without an error and the menu renders. Before the fix, the same page showed "The website encountered an unexpected error" when Twig Tweak was not installed. No component uses drupal_menu() anymore.

 1. Pulled the latest 2.x. 2. Uninstalled Twig Tweak and cleared the cache. 3. Opened /admin/appearance/ui/components/sdc_components/menu.  Result: the page loads without an error and the menu renders. Before the fix, the same page showed "The website encountered an unexpected error" when Twig Tweak was not installed. No component uses drupal_menu() anymore.  Screenshot attached: the menu page with Twig Tweak uninstalled.  The fix works for me. Thank you for the quick fix!  AI disclosure: I used Claude to help me with the testing steps and to write this comment. I ran the tests myself and checked the results.

The fix works for me. Thank you for the quick fix!

AI disclosure: I used Claude to help me with the testing steps and to write this comment. I ran the tests myself and checked the results.

flyke’s picture

Status: Reviewed & tested by the community » Fixed

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.