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.
Comments
Comment #10
danielvezaWith #3027653: Allow block and layout plugins to determine if they are being previewed being committed, is this issue still required?
Comment #11
danielvezaAs per #10, it appears that another issue has already provided the required functionality. There has been no further updates to this issue since the last comment over three months ago, so I'm now marking this as closed.
Thanks!