Gutenberg: Legacy Widget: Users should be able to transform a legacy Text widget into a Paragraph block

Created on 7 Sep 2020  ·  12Comments  ·  Source: WordPress/gutenberg

Split out from https://github.com/WordPress/gutenberg/issues/15911.

It's not currently possible to transform a legacy Text widget into a Paragraph block.

Steps to reproduce:

  1. Navigate to /wp-admin/widgets.php by manually entering the URL into your browser.
  2. Add a Text widget to one of your widget areas, insert some text, and click _Save_.
  3. Go to Appearance → Widgets.
  4. Select the Legacy Widget block that corresponds to the Text widget that you just added.
  5. Click on the block icon in the block toolbar to open the _Transform to_ menu.

Expected result:

An option to transform the widget into a Paragraph block should appear.

Actual result:

Screen Shot 2020-09-07 at 11 07 03

Only an option to transform the widget into a Group block appears.

[Block] Legacy Widget [Block] Paragraph [Type] Bug

Most helpful comment

So the thing I see here is that transform should be available if the widget developer (including core) provided such a transform, where the legacy widget block is transformed to another proprietary bloc (say Astra address widgets to Astra address block).

A convert to blocks option would mean (to me at least) a generic attempt to convert the widget's rendered html to a series of blocks, like we do with the classic block conversion to blocks.

I am not sure this is entirely possible though as some widgets render with contextual information.

All 12 comments

As mentioned in that original issue that I created (#15911), it's not good enough to simply transform a legacy Text Widget into a Paragraph Block. In fact, it's impossible to do so.

A widget is more than just the main content, it's also a header, and in the case of a Text Widget, it may be one or more Paragraphs of content. Since you only allow 1 paragraph per Paragraph Block, it's simply not possible to convert a single legacy Text Widget into a single Paragraph Block. You would need to transform it into one Heading Block, and one or more Paragraph Blocks. It may even be better to transform it into a Heading Block and a Classic Block, that way you wouldn't need to split the content into multiple paragraph blocks.

Likewise with any of the existing widgets. You need one Heading Block, and some other block. You can't simply ignore, or forget about the headings in the legacy Widgets.

This is one of the items I also mentioned as well, in regards to this whole widgets UI. Having to add multiple blocks, just to replicate one widget in the classic Widgets screen, is making it a LOT harder for people to migrate to the new Widgets screen, and also makes it significantly harder to maintain going forward. I've now gone from 5 simple widgets, to a minimum of 10 blocks, and in some case, it could be 15 or 20 blocks. This is not making WordPress easier to manage for users.

Thanks for flagging @maddisondesigns. Perhaps instead of adding a Paragraph transformation we need to add a _Convert to blocks_ button similar to what the Classic block has.

@mapk: Does adding _Convert to blocks_ to the Legacy Widget block's toolbar when the widget is a Text widget make sense to you?

@noisysocks Having a _Convert to blocks_ button sounds like a really good idea 👍

@mapk: Does adding Convert to blocks to the Legacy Widget block's toolbar when the widget is a Text widget make sense to you?

Yes! I'd love a way to easily convert widgets (that _can_ be) to blocks! In this way the Legacy Widget block aligns with the Classic block. Maybe the naming should also align? _Classic Widget block_ ?

Let's also make sure that button doesn't show up unless it's possible to convert, right?

I would imagine it looking similar to this:

Text widget

Just to confirm @mapk @noisysocks - is this issue about adding "Convert to blocks" button to the "Legacy Widget block of type text widget"? Or to "all legacy widget blocks that are possible to transform to another block"? If it's the latter - it would be pretty much the same as the existing "Transform" dropdown, only more identifiable.

Thanks for flagging @maddisondesigns. Perhaps instead of adding a Paragraph transformation we need to add a Convert to blocks button similar to what the Classic block has.

I don't quite follow @noisysocks - would you mind elaborating? My thinking is that converting the widget to a heading and a paragraph block using a new kind of button would be essentially working around the limitations of transformations, no? If we add that button to one legacy widget, it would only make sense to add it to all other legacy widgets for consistency. Couldn't we just improve transformations and make the transform button more visible? Or convert it to a group of blocks?

@adamziel, the "Convert to blocks" button is a existing pattern used on the Classic block.

Classic block

Screen Shot 2020-09-18 at 9 42 05 AM

I believe the proposal here is to mimic this behavior for widgets that have a block equivalent and can easily be converted to blocks. It's different from a transform, IMO.

@mapk thank you for providing the classic block example! While I think I understand the idea, it feels a little confusing to me:

  • Having both "Transform to blocks" and "Convert to blocks" would be confusing.
  • Having some widgets that have "transform" button and some others that have "convert to blocks" would be confusing.
  • Having only "Convert to blocks" would be consistent, but would prevent plugin authors from providing their own transforms...
  • ...unless we make "convert to blocks" a dropdown and provide multiple options whenever they're available. But it seems to be the same as the existing "Transform to blocks". At a very least it would use the same transforms API.

I think we should just enhance transforms to support the missing use-case. Labeling the transform button to "Convert to blocks" could be a nice UX touch on the legacy block. I'd love to hear more opinions here too, cc @youknowriad @noisysocks @draganescu @talldan @tellthemachines

One more note - I imagine for most widgets "Convert to blocks" would apply the first available transform. Text widget is the one case we know about where it would do something different. Unless it's only enabled for the text widget? 🤔 I also imagine it should be extendable by plugin authors.

So the thing I see here is that transform should be available if the widget developer (including core) provided such a transform, where the legacy widget block is transformed to another proprietary bloc (say Astra address widgets to Astra address block).

A convert to blocks option would mean (to me at least) a generic attempt to convert the widget's rendered html to a series of blocks, like we do with the classic block conversion to blocks.

I am not sure this is entirely possible though as some widgets render with contextual information.

I believe @draganescu is correct here. A "Transform" is a 1:1 block transform – _a block is transformed into another block_. A "Convert" is converting non-blocks (could be many elements) into corresponding blocks. That's how I understand it. I'm fairly certain this same conversation must have come up about the Classic Editor block. I wonder if the reasoning for the decision to add a "Convert to blocks" button would be helpful here?

Definitely agree that _transform_ and _convert_ are technically two different concepts. Whether they're treated as different concepts in the UI is another story.

How can we move this one specific issue forward? I think the simplest path is to add _Convert to blocks_ to only the Text widget. This mirrors the behaviour of the Classic block.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

davidsword picture davidsword  ·  3Comments

BE-Webdesign picture BE-Webdesign  ·  3Comments

hedgefield picture hedgefield  ·  3Comments

franz-josef-kaiser picture franz-josef-kaiser  ·  3Comments

pfefferle picture pfefferle  ·  3Comments