Problem/Motivation
When saving a block in Layout Builder that uses the Media Library dialog, the AJAX request runs under the admin theme. This prevents the Layout Builder preview from rendering correctly in the frontend theme. Additionally, admin theme callbacks (such as gin_form_after_build) are not loaded, which leads to errors like:
TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, function "gin_form_after_build" not found or invalid function name in call_user_func_array() (line 1085 of /var/www/html/docroot/core/lib/Drupal/Core/Form/FormBuilder.php).
Steps to reproduce
- Open a Layout Builder page for a node.
- Add a block that contains a Media Library field (opens in a dialog).
- Save the block configuration.
- Observe that the preview blocks may render incorrectly.
Proposed resolution
We no longer rely on the AJAX request’s theme, since it may originate from the admin theme. Instead, we conditionally load the admin theme callbacks using loadAdminThemeCallbacks() to ensure that form callbacks like gin_form_after_build() are available, preventing errors while still allowing the Layout Builder preview to render in the frontend theme.
Remaining tasks
- ✅ File an issue about this project
- ✅ Addition/Change/Update/Fix to this project
- ✅ Testing to ensure no regression
- ➖ Automated unit/functional testing coverage
- ➖ Developer Documentation support on feature change/addition
- ➖ User Guide Documentation support on feature change/addition
- ➖ UX/UI designer responsibilities
- ➖ Accessibility and Readability
- ✅ Code review from 1 Varbase core team member
- ✅ Full testing and approval
- ✅ Credit contributors
- ✅ Review with the product owner
- ✅ Update Release Notes and Update Helper on new feature change/addition
- ✅ Release varbase-10.1.0-beta1, varbase_layout_builder-10.2.0-beta3
Varbase update type
- ✅ No Update
- ➖ Optional Update
- ➖ Forced Update
- ➖ Forced Update if Unchanged
User interface changes
- N/A
API changes
- N/A
Data model changes
- N/A
Release notes snippet
- #3545316 Fix: Theme negotiator rendering Layout Builder preview blocks after saving a block using Media Library dialog By: n.ghunaim
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3545316-5.patch | 2.83 KB | n.ghunaim |
Issue fork varbase_layout_builder-3545316
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
Comment #3
n.ghunaim commentedComment #4
n.ghunaim commentedComment #5
n.ghunaim commentedComment #6
n.ghunaim commentedComment #7
n.ghunaim commentedComment #8
rajab natshahComment #10
rajab natshahComment #11
rajab natshahComment #12
rajab natshah✅ Released varbase_layout_builder-10.2.0-beta3
Comment #13
rajab natshahComment #15
rajab natshah✅ Released varbase-10.1.0-beta1