-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't edit or preview block widgets in the customizer #25818
Comments
Would appreciate some more technical information on this, where should anyone interested in contributing to problem solving this issue look to try to understand the issue? (cc @adamziel, @draganescu )
Some more info on these points would be great, how is it working right now? |
@talldan the way customizer makes the widgets preview work is this:
There is also a lot of both JS and PHP logic in place to make sure the preview will render the updated widget even if you click a link or submit a form. Some of it fakes the value of stored widget options to make sure they're rendered correctly after the page reloads. See There are also pencil icons rendered next to every widget in the preview. When clicked, they move the focus to a related form. Now, the problems are:
I was able to come up with the following ideas:
|
Thanks @adamziel, this helps a lot. |
@westonruter Hope you don't mind the ping. Looking back through the code history I notice you've contributed considerably to this part of the codebase. Any suggestions or ideas on integrating the block-based widgets screen? |
I'm not entirely clear what the scope is here. Is it about adding widgets as blocks, or about “widget blocks” (e.g. Latest Posts) in new block areas? Is this about editing in the Customizer or editing widgets in the admin screen? When widgets were added to the Customizer originally, there was a ton of work needed to shim the legacy PHP-centric widget UI into the Customizer which is JS-centric. This is why there's all the mess of hidden inputs that are passed around. However, since blocks are JS-based then this mess should be avoidable. A block's attributes can be stored neatly in a Customizer setting, and changes to the Customizer setting will sync automatically to the preview for rendering. This being said, I think the blocks should really be edited inline in the preview, and the block settings sidebar should be put in the Customizer sidebar. When a block is selected, it could go into edit mode in the preview and then once deselected it can be re-rendered server-side using selective refresh. A challenge here is the editing of the block would be happening in two different windows, and so the settings would need to be synchronized across the windows via |
My understanding is that the goal is to allow blocks to be added to widget areas alongside legacy widgets. By doing this widget areas become "block areas". I agree with everything that @westonruter said. Integrating JS-based Gutenberg blocks with the JS customizer API should not be as difficult as the original widget integration with the customizer was. It seems like the problems with integrating Gutenberg and the customizer to date are that customizer settings are not being leveraged to their full extent. I also agree that blocks should be edited in the preview (front end). But, based on the non-contextual approach that Gutenberg takes it does seem appropriate to keep widget/block editing separate from the preview in this first step, and then to move all editing to the preview (frontend) eventually. And this would also enable a similar approach to be used for both the wp-admin widgets screen and the customizer. See #26012 for my detailed proposal for using the customize API for both widget screens. If that proposal isn't adopted for the standalone screen, it still applies as an option for widget-blocks in the customizer. |
This issue initially was about having a new customizer tab that would be a large block editor that would be a customizer-embedded version of the experimental editor. Since that turned out to be pretty challenging, I propose an alternate approach where we embed multiple block editors in the customizer: That PR is by no means mergeable, it's more like a discussion prompt cc @draganescu @talldan @celloexpressions @westonruter @noisysocks @tellthemachines |
Copying some thoughts I had over in Slack here:
|
I wouldn't necessarily say that this is true even without blocks. Why can't the editor work with the markup that the theme provides? And transform it as required while in edit mode. The front end editor plugin has good previous explorations of this concept (pre-block editor): https://wordpress.org/plugins/wp-front-end-editor/
For post content, and maybe also widget content, inline editing is probably a better experience, where the sidebar contains block settings similar to the post editor.
I propose this approach as the first step in #26012. There is precedent for this in the customizer's themes panel.
Also proposed in #26012 and seems like a good direction. I agree that #26155 doesn't feel like the right direction. |
Rendering the block editor requires rendering each block's There has been some exploration into making it so that the editor uses the actual block markup that is shown on the frontend, which could make inline editing possible. But, to my knowledge, it's still very early days. |
I'm going to close this out as we're now tracking the work of adding block-editor to the Customizer in various other places:
Thanks everyone! (Especially @celloexpressions and @westonruter – your notes here were very helpful!) |
The new Widgets editor should have it's features present in the customizer as well and preview and update (publish) of changes should work as they currently do.
It appears that there is a problem with making the Customiser auto refresh and auto update the changes made to blocks. (#25157, #25153, #25154)
When the embedded Gutenberg editor in the customiser's sidebar has some changes, the changes are not picked up by the auto preview system, because it expects a certain HTML to exist. Also, it seems the object based architecture of the whole Customiser encapsulates things in a way that makes the widget auto preview API not available if each control is not registered before.
The JS API of the customiser leads to a solution where we don't replace the widgets panel with a full blown editor, but instead we maintain it and each widget will show up as it does today, plus the blocks as a Block widget.
The more complex option is to instance a small editor for each block widget and maybe that would be picked up by the auto preview system, as it contains generic inputs, but no guarantees.
The text was updated successfully, but these errors were encountered: