Skip to content
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

Widget Editor: Reconstruct Widgets Screen to use the Customize API #26012

Closed
celloexpressions opened this issue Oct 12, 2020 · 11 comments
Closed
Labels
[Feature] Widgets Screen The block-based screen that replaced widgets.php. [Type] Discussion For issues that are high-level and not yet ready to implement.

Comments

@celloexpressions
Copy link

There are several fundamental problems with the current approach to the widgets screen. This issue outlines an alternative approach that leverages existing WordPress core functionality to improve user experience and minimize reinventing the wheel. It streamlines the process of bringing blocks to the widgets screen and to the customizer.

Much of the current implementation could remain as-is, but the underlying technical foundation will be reworked. The user interface could be refined as a result and the user experience benefits significantly. The design could be similar to what is currently proposed or evolve as desired.

Why Now? (Before First Release of the Widget Blocks Screen, Proposed WordPress 5.6)

The Gutenberg plugin currently supports a new widgets screen with blocks. But there is no support for block-widgets in the customizer. This introduces several challenges:

  • Blocks cannot be added to widget areas with contextual live preview (in the customizer).
  • Only some widgets in the customizer are editable, blocking user flow.
  • The new widgets screen and widgets in the customizer are separate technical implementations, amplifying technical debt and increasing the burden of maintaining future compatibility in WordPress core.
  • Plugins extending the widget editors must contend with multiple divergent interfaces in core.
  • Plugin authors cannot reliably convert their widgets to blocks because those widgets would no longer be usable in the customizer.
  • The widgets screen remains severely crippled in functionality. “Change and surprise” becomes “save and surprise” and it remains impossible to contextually preview without publishing. Or to schedule or draft changes.

Generally, the current approach creates several disruptions to user flow. In contrast, reconstructing the widgets screen to leverage the customize API has several benefits:

  • Widget edits can be drafted, scheduled, and shared before publishing.
  • We can support a contextual (and optionally live) preview of all changes to widgets.
  • Concurrent editing can be blocked (for now) and eventually enabled consistently.
  • The same interface can be used in both the customizer and wp-admin, or this could eventually be unified into one location to manage widgets.
  • There is reduced technical debt and future maintenance burden in WordPress core.
  • We can improve the transition from editing posts in wp-admin to editing all content in a unified front-end-oriented interface while maximizing backwards compatibility.

Any change to the existing widgets screen will disrupt existing user flows. A vocal group of users expressed this concern when widgets and menus were originally added to the customizer. Let’s take the time to make sure the new experience is better, and to go through this disruption only once.

Why the Customize API?

The customizer is a framework for live-previewing changes to a site. It is not, necessarily, the specific interface that most of us are familiar with at wp-admin/customize.php. The power of the customizer is its API and its contextual live preview – the ability to instantly see edits as they apply on the frontend of the site. Users can navigate to different pages on the site within the preview; for widgets, this makes it easier to understand how dynamic and conditionally-visible widgets work across a site.

Most importantly, the customizer allows users to schedule changes, save draft changes, and even share a public link to navigate through the site with a preview of changes. The widgets screen has long suffered from a "change and surprise" publishing experience. The Gutenberg plugin’s new widgets screen currently has only a publish button with none of the other features.

We can leverage the customizer API outside of wp-admin/customize.php to bring this enhanced publishing experience to the standalone widgets screen (specifically, this is the customize changesets API). We can also offer a "preview" button that opens a standalone customizer preview of the frontend of the site reflecting changes to widgets.

Previewing Widgets

Once widgets are managed with the customize API, we enable previews of widget options using existing core functionality. There are several ways to show these previews:

  1. Live inline pseudo-preview (Gutenberg editor does this)
  2. Live standalone preview (this is part of what the customizer does)
  3. Standalone contextual preview (Gutenberg does this in a new tab, customizer does this on mobile)
  4. Contextual live preview (customizer does this)

The preview under option 3 could open in a new tab similar to the editor preview. But, because we're using the customize API, we could also open it as a full-screen or modal overlay. The editor/preview toggle could be similar to the mobile interface that the customizer currently uses. This is contextual, but not live, preview. Exceptionally large (desktop) monitors might show a live preview next to the editor (option 4). Blocks already do inline preview (option 1), but traditional widgets are not as successful in this format.

Contextual preview (via options 3 or 4) is critical to widgets because they aren’t consistent across all pages on a site. Some widgets include dynamic content based on the current view. Others may have conditional visibility. Most frequently, a given widget area may not be shown in all views. Without contextual preview, widgets and blocks in widget areas cannot be reliably tested and reviewed before being published to the live site.

Technical Approach

How can we leverage the customize API for the widgets screen? Here are a few steps aligned with the customizer object structure:

  1. Merge blocks with legacy widget customize controls. This is the editing UI for individual widgets and blocks (rebuilt WP_Widget_Form_Customize_Control). There could be different control classes for blocks vs. legacy widgets as appropriate.
  2. Merge block settings with customize settings. This is they key element that unlocks support for saving, previewing, and publishing. May involve a setting extending WP_Customize_Setting and/or primarily work in JS. There could be different setting classes or types for blocks vs. legacy widgets as appropriate.
  3. Update widget area customize sections to the new design used on the widgets screen. This is a reworked (and maybe new/renamed) WP_Customize_Sidebar_Section, which controls the order and interaction between blocks.
  4. Create a new WP_Customize_Widgets_Panel, extending WP_Customize_Panel. See WP_Customize_Nav_Menus_Panel and WP_Customize_Themes_Panel for examples. This is the “screen” that holds all of the widget areas. It includes the widget inserter and block areas/block settings sidebar. And it’s responsible for the overall screen layout (“taking over” the customizer preview for the customizer version).
  5. Update the add-widgets/block inserter to create the appropriate customize controls and settings, adding the controls to the appropriate customize section.
  6. Bootstrap an instance of the customizer on wp-admin/widgets.php. This instance will only load the widgets panel and associated controls. See https://core.trac.wordpress.org/ticket/29071 for some background and links to examples.
  7. Implement supplementary UI for the preview, save, schedule, and publish functions on the standalone customizer instance. Essentially, add everything managed directly by wp-admin/customize.php. Includes design decisions on how to handle previews.
  8. Where the preview approach is live (within the customizer), verify that the customize selective refresh functionality triggers whenever edits are made. JS-managed blocks should be able to handle previews instantly through postMessage.

All of this could be built in the plugin first by selectively extending and replacing elements (customize remove_* functions, dequeuing scripts) of the current customize-widgets infrastructure. The customizer PHP API is more stable and fully-featured that the JS API. This could be a great opportunity to improve the JS side and coordinate with the approach that Gutenberg takes with JavaScript. All of the object references above apply to both the PHP and the JS aspects of the API.

A Path toward Integrating Gutenberg with the Customizer

If the goal of the standalone widgets screen is to provide a full-screen experience for editing widgets, then it shouldn't use the same interface that widgets in the customizer currently use. But with block editing incorporated into widget editing, maybe customizer widgets should also offer a more-full-screen editing interface.

Customizer panels (widgets, menus, etc.) can take any form that's appropriate for the feature. The theme browser takes over the customize preview to offer a full-screen.) Why not do the same for widgets? With this approach, the widgets screen and widgets in the customizer can use exactly the same interface with exactly the same technical implementation as a customizer panel.

Do we need to offer the same interface in two different places? At that point, we can unify to a single full-screen widget editor that is powered by the customizer behind the scenes. We can keep links to the widgets screen as links that go directly to the full-screen widgets panel in the customizer. And users can also get to the widgets screen from directly within the customizer, without leaving the site customization scope. Or we can keep separate screens but use the same infrastructure and interface in both places. Either way, this general strategy brings Gutenberg into the customizer and demonstrates a path forward for integrating other parts of Gutenberg with the customizer.

Longer term, there becomes a clear path forward:

  1. Integrate Gutenberg blocks into widget areas, editing them in a full-screen customizer panel.
  2. Enable post editing within the customizer API with a similar approach to the widgets panel. Most site content (but not structure) can now be managed in a unified interface.
  3. Move widget and post editing from separate panels to inline editing in the customize preview. This is inline-edited contextual live preview on the frontend of a site.
  4. Add support for full site editing, or editing the site structure with block templates. This can live within the customizer to provide contextual live preview with the customize changesets publish flow.

Note: full site editing as currently conceived is a new feature set introduced to core that individually benefits from the customizer’s contextual live preview. It does not replace the role or functionality of the customizer. Step 4 outlined above would be a good opportunity to implement site structure editing with post and other content area editing and other features in the customizer to create a unified site management experience that prioritizes contextual live preview.

Conclusion

The widgets screen in the Gutenberg plugin currently feels very "alpha". From accessibility to publishing flow there is work to do. We have an opportunity to significantly improve the experience and reduce technical debt by leveraging the customize API in the technical implementation. And we can bridge the gap between the editor, Gutenberg, the widgets screen, and the customizer in the process.

This may not be achievable in time for WordPress 5.6. But it is a better approach than the current separate implementations. Focusing on a single implementation, we can focus on critical needs such as accessibility. And we can create a better editing experience for all users.

@derekherman
Copy link

This is a great proposal @celloexpressions, where are things at and how can people support you moving it forward?

@celloexpressions
Copy link
Author

This should be on hold pending the outcome of blocks in the customizer (#26900, now #27343). If that experience is similar enough to the widgets screen, or significantly better, then it may be best to merge the widgets screen into the customizer.

If the widget screen stays, then this proposal applies. The goal is to enable the things that the customize API does -- notably preview and changesets (drafts, scheduling, etc). Hopefully the blocks-in-customizer work will make this easier to integrate. I could see this as a detailed integration as described above or more minimally integrating blocks with customize settings to make this happen.

@noisysocks noisysocks added [Feature] Widgets Customizer Ability to add and edit blocks in Customize → Widgets. and removed Customizer [Feature] Widgets Screen The block-based screen that replaced widgets.php. labels Jan 5, 2021
@draganescu
Copy link
Contributor

As noted pending: #27343

@noisysocks noisysocks added Needs Decision Needs a decision to be actionable or relevant and removed Needs Technical Feedback Needs testing from a developer perspective. Needs Decision Needs a decision to be actionable or relevant labels Apr 8, 2021
@noisysocks
Copy link
Member

I forgot to thank you @celloexpressions for this really well thought out issue. It definitely influenced the way I think about this project and it has inspired a lot of the work that @kevin940726 and I done.

There is now experimental support for block widgets in the Customizer. Check it out if you haven't already by enabling the flag in Gutenberg → Experiments.

I think that these three points are now sufficiently addressed:

  • Blocks cannot be added to widget areas with contextual live preview (in the customizer).
  • Only some widgets in the customizer are editable, blocking user flow.
  • Plugin authors cannot reliably convert their widgets to blocks because those widgets would no longer be usable in the customizer.

The remaining points you raised are still relevant today:

  • The new widgets screen and widgets in the customizer are separate technical implementations, amplifying technical debt and increasing the burden of maintaining future compatibility in WordPress core.
  • Plugins extending the widget editors must contend with multiple divergent interfaces in core.
  • The widgets screen remains severely crippled in functionality. “Change and surprise” becomes “save and surprise” and it remains impossible to contextually preview without publishing. Or to schedule or draft changes.

The third point can be addressed by adding Preview functionality to the Widgets screen. This would be implemented using Customizer APIs. It is not clear whether we could/should do this for v1.

I think that the fundamental question, which I'd like to discuss, at the core of these three points is: What value does the Widgets screen have for users over the Customizer? Should we maintain both screens now and into the future?

cc. @shaunandrews @critterverse @kevin940726 @talldan @tellthemachines @draganescu @TimothyBJacobs

@critterverse
Copy link
Contributor

critterverse commented Apr 8, 2021

Hi all, very new to the project but just wanted to offer my top-level thoughts and congratulations on how far the work has come to revolutionize the experience of editing Widgets already.

What value does the Widgets screen have for users over the Customizer? Should we maintain both screens now and into the future?

As a designer, the instinct to simplify/streamline is strong, and I am hopeful that the standalone screen can go away.. eventually… in due time… 😂 From a user perspective — and maybe this goes without saying — it’s very confusing to see the two different screens accessible within the same site.

After chatting with @draganescu and @shaunandrews about this, I can appreciate that this is anything but straightforward and that the standalone screen does need to stay around to support existing user flows. But I’m supportive of plans to try to merge these screens into a single experience in the future.

With this approach, the widgets screen and widgets in the customizer can use exactly the same interface with exactly the same technical implementation as a customizer panel. Do we need to offer the same interface in two different places? At that point, we can unify to a single full-screen widget editor that is powered by the customizer behind the scenes. We can keep links to the widgets screen as links that go directly to the full-screen widgets panel in the customizer.

This approach proposed by @celloexpressions sounds really powerful to me. If we were able to do something like this eventually, one alternative to keeping the existing link in the Appearance menu permanently could be to leave it there temporarily to provide a user education moment during a timed phaseout — I can imagine having a note/link somewhere saying, “Widgets have a new home. They’ve been fully integrated into the Customizer where you can now schedule changes, save draft changes, and even share a public link to navigate through the site with a preview of changes 🎉“

While these changes would alter the existing flow for users who know and use the standalone screen, I think ultimately it would make for a cleaner, more simplified user experience overall.

Anyway, these are just my early thoughts on where things might go in the future, and apologies if I’m glazing over some important technical concerns. This project is even more impressive after learning about some of the technical hurdles that have already been overcome, and I'm excited that it's positioned to have such a huge impact. Well done all! 🚀

@noisysocks
Copy link
Member

After chatting with @draganescu and @shaunandrews about this, I can appreciate that this is anything but straightforward and that the standalone screen does need to stay around to support existing user flows.

What existing flows does a block-based Appearance → Widgets screen support?

Because the block-based Appearance → Widgets screen is a completely new screen, many plugins that use the old Appearance → Widgets screen will need to be updated. As one example, this plugin which allows users to add custom sidebars will need significant changes if it wishes to support the new screen.

In other words, if we are going to consolidate Appearance → Widgets and Appearance → Customize → Widgets, now is probably the time to do it since third parties will need to make changes one way or the other.

@noisysocks
Copy link
Member

noisysocks commented Apr 9, 2021

I think we should seriously consider consolidating the two screens.

Right now, the block-based Appearance → Customize → Widgets screen already has several advantages over Appearance → Widgets:

  • Easy discoverability of widget areas via Customize button which appears in toolbar of every frontend page.
  • Real time preview.
  • Changes can be saved as a draft.
  • Changes can be scheduled.
  • Changes can be shared via a link with other users.

The block-based Appearance → Widgets screen does have a few advantages over Appearance → Customize → Widgets, but I think that they are less compelling:

If the above improvements are made to the block-based Appearance → Customize → Widgets screen, consolidation could be quite straightforward.

We could delete the block-based Appearance → Widgets screen, make Appearance → Widgets link directly to the relevant part of the Customizer, and maintain the old widgets.php screen as a way to achieving backwards compatibility with plugins that use/extend it.

Widgets screen

@celloexpressions
Copy link
Author

I have been strongly in favor of merging the two interfaces for a long time. The "manage with live preview" link, and various other link adjustments were initial steps in that direction. The separate widgets screen generally still exists because some people are accustomed to it and there are potential backwards compatibility issues with removing it. The same goes for the menus screen (and my proposals to consolidate that date back to the original menu customizer merge proposal for WordPress 4.3). It would also be critical to confirm that block-widgets in the customizer are accessible enough to lose the widgets screen "accessibility mode."

The present block-ification of the widgets screen seems like a great opportunity to "flip the switch" on this. The screen is drastically changing, which will prompt the potential breakage and re-learning that would also happen by consolidating with the customizer. This idea likely warrants broader discussion (via a Make/Core post next?) to validate this idea and work toward a final decision.

Consolidating to one widget editor should enable the team to address the few present advantages of the standalone screen in the customizer for better feature parity. And would generally allow everyone to focus on polishing, extending, and learning how to edit block widgets in one canonical place.

@draganescu
Copy link
Contributor

My main concern with deprecating the standalone editor is that we may be boxing ourselves in, while also possibly miss out on the options open by upgrading widget areas with blocks support.

Widgets living alongside blocks are a great opportunity to build upon. What today is sidebars, next year could become block areas, or block templates. Upgrading "sidebars" to "block templates" that are immediately editable and require no migration, no setup or opt-in, should have a great value for classic themes (including financial value). This is still possible after removing the stand alone screen, but cramped by the compromises we need to make in the Customizer.

While the live preview is a great feature to have, the block editor is really, simply, much better when expanded, as we struggled with this from the very start of Gutenberg: all the screen or just the editor? All the screen "won" for a reason. While we do have an idea to expand the sidebar and bolt a full page editor in, it is not the same thing, and to make it the same thing we need to invent new UX/UI on top of the block editor’s already invented UX/UI.

The editor in the Customizer's sidebar is not behaving like the other editors. It requires special treatment. If we opt to go on this route alone, we also should strap ourselves to always have to invent ways to do things in the “Customizer block editor” whenever the editor evolves, while the stand alone editor inherits, not only functionality but new UX paradigms as well.

In a future with block templates for classic themes, working on them in isolation, in a block editor that will match the front end 100%, is a far more productive and intuitive experience. The long term striving should be that we make the editor be faithful of the frontend, not rely on a refreshing preview. Removing the stand alone editor "removes" this idea and possibility. Obviously you can bring it back, but we're not supposed to "move fast and break things".

There are other things to be said about the widgets screen:

  • I don't know if in terms of accessibility the Customizer's constrained block editor can be better or similar than the full page block editor. This is not only about keyboard access, but also about how visible and reachable things are.
  • There is a use case that the stand alone editor serves, for quick updates to those many very small sites ran by people as a hobby. Not everyone wants to "preview" anything, or has a staging website. From that 40% of the web on WordPress there are at least hundreds of thousands of websites that get visited by the author's friends and family.
  • For some, the experience of "customizing a sidebar" is foreign, they just want to add a picture to the footer, or next to the post's text, and that is how they did it in the past ten years, in its own separate space, not by drilling in some nested menu two times. While the old screen's ways are archaic for new WordPress users, the upgraded screen solves that. Removing it though, may break the experience even for new WordPress users who could use a simple and straightforward way better.
  • The customizer did not really onboard everyone. While the manage with live preview link was there for quite a while, there are still people who default to that screen to manage widgets. It is unknown to me whether they stuck with the screen because they generally don't use the customizer or because of some limitation of the customizer's widget management. I remember a problem with "seeing everything at once" which is not a problem really.

As a final note, there is a whole conceptual problem on whether using, creating and setting up widgets is an action of customization or of content management. On what basis do we decide the chrome around the content cannot hold content? If it weren't content maybe we wouldn't hear requests to add classic block support. If it is content then it mandates its own particular stand alone approach.

Considering all the above, I am not against removing the screen. I do however find that the reason of "it's a good time to do it" is not a wise one, and the solution we end up with does not seem to capture everything we'll be missing out on. This decision needs two things:

  • A holistic overarching hope. Do we aim to eventually move more and more of wp-admin to the Customizer? There are plenty of other things that are achievable in at least two places in WP Admin.
  • Involving the folks where core updates are discussed, in Trac. I'll make a ticket or see if there is one to be resurrected around this idea.
  • YES to having a make block post and open this idea for discussion. This post could at least wipe off all my bullet list above.

@celloexpressions
Copy link
Author

The widget-block editor in the customizer needs to be equivalent to or better than the standalone screen as a prerequisite to considering consolidation. It's not there yet, but the vision could be there. Making a decision along the way would also allow focus on making one interface great.

I'm not convinced that the block editor belongs in a sidebar UI. In fact, I think a modal overlay or inline-preview approach would better relate to the current post editor and reflect the idea that the block editor provides an inline live preview. A full-screen widget/block editor located in the customizer has the advantage of offering high-fidelity contextual previews in addition to the inline live previews. The "unexplored" ideas in #27343 should be revisited, as the sidebar block editor doesn't work well in practice. Widget editing made more sense in a sidebar because the options were highly abstracted. That's not the case with blocks.

We don't need to compromise the customizer experience to work around a sidebar/preview UI. The customizer is more of a wrapper - its individual features can and should adapt the UI where appropriate. See the theme browser for example - it doesn't need the preview window, so it hides it. Block-based widgets can hide part or all of the preview while editing, and keep the preview handy for review before publishing (and with benefits like not having to open another tab).

A holistic overarching hope. Do we aim to eventually move more and more of wp-admin to the Customizer? There are plenty of other things that are achievable in at least two places in WP Admin.

My long-term hopes for the customizer are to consolidate most aspects of wp-admin into it and to improve its relationship to the frontend (improving contextual editing/customization). I outlined some specific next steps in the introduction to this issue:

Longer term, there becomes a clear path forward:

  1. Integrate Gutenberg blocks into widget areas, editing them in a full-screen customizer panel.
  2. Enable post editing within the customizer API with a similar approach to the widgets panel. Most site content (but not structure) can now be managed in a unified interface.
  3. Move widget and post editing from separate panels to inline editing in the customize preview. This is inline-edited contextual live preview on the frontend of a site.
  4. Add support for full site editing, or editing the site structure with block templates. This can live within the customizer to provide contextual live preview with the customize changesets publish flow.

Editing posts in the customizer wouldn't replace the standalone editor for most cases, but would make it easier to edit page contents alongside templates. This would be particularly useful for things like homepages. It streamlines the flow between editing different parts of a site with a unified focus on the frontend preview. The idea is to click "Customize" in the toolbar from a page on the frontend and go straight to the interface where you can edit any part of that frontend page.

Step 3 on my list might happen with step 1 depending on approach. Step 4 could be its own project, or potentially be the landing place for the site editor (specifically template editing). See #30496 "Approach 2" for a potential strategy there.

@noisysocks noisysocks added [Type] Discussion For issues that are high-level and not yet ready to implement. [Feature] Widgets Screen The block-based screen that replaced widgets.php. and removed [Feature] Widgets Customizer Ability to add and edit blocks in Customize → Widgets. labels Feb 21, 2022
@draganescu
Copy link
Contributor

While this has served everyone well by providing great insight and exploration paths, given the current implementation I think it's safe to close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Widgets Screen The block-based screen that replaced widgets.php. [Type] Discussion For issues that are high-level and not yet ready to implement.
Projects
None yet
Development

No branches or pull requests

6 participants