Add a Preview build interface

Created on 27 April 2019, over 5 years ago
Updated 18 July 2024, 3 months ago

Problem/Motivation

Currently in the Layout Builder UI all block plugins are built and if the content is empty a preview fallback is applied if possible and otherwise a generic fallback.

One problem with this approach is block plugins using forms #3045171: Form blocks rendered inside layout builder break save
And there might be more undiscovered problems that we are not aware of.

#3027653: Allow block and layout plugins to determine if they are being previewed attempts to solve this by allowing a plugin to know if it’s being previewed or not.

This issue proposes an alternative solution.

Add an optional interface, PreviewBuildInterface that exposes a “buildPreview” method. If the block plugin implements that interface, the Layout Builder UI will call that method for its rendering of the block. If not, a fallback will be used. This removes all the logic to try to determine if the block works in the UI.

Additionally, it creates a distinction between preview and fallback.

Plugins build method doesn’t have to conditionally render for preview.

All block plugins would work in Layout Builder UI (the fallback) and is not required to be compliant. This is less error prone than guessing if the block contains something that would break the UI.

Most plugins could simply return the build to be compliant (no complexity required)

Proposed resolution

Add a new interface.
Implement in core’s block plugins.

📌 Task
Status

Closed: outdated

Version

11.0 🔥

Component
Layout builder 

Last updated about 6 hours ago

Created by

🇸🇪Sweden johnwebdev

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024