WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.36k stars 4.13k forks source link

List View: Explore hiding blocks #50756

Open richtabor opened 1 year ago

richtabor commented 1 year ago

To complement https://github.com/WordPress/gutenberg/issues/33583, it would be interesting to have a way to hide a block within the editor, which results in the block not rendering on the front end.

If we could visually hide a block in the editor, and stop it from rendering on the front end, designers could lay out a couple iterations of an idea—turning on/off various groups—instead of various process hacks to exploring today.

Some ways I achieve this now are to leverage the undo button (or copy/hold in the clipboard)—but it only goes so far. Otherwise, I've ended up creating reusable blocks of ideas I don't want to loose, or random pages with groups of blocks on them. Not ideal.

Proposal

Consider having a hide/show control available within List View, that shows up with the same conditions as the block options control that's already in place. When toggled on, that block does not render within the editor or the frontend of the site.

Visual

hiding-blocks
nekohayo commented 1 year ago

In conjunction with configurability in the block properties sidebar, this would also be very useful for:

Of course there is the tricky part where when a condition changes internally (ex: date/time change) you may need to tell the caching plugins (such as the WP Super Cache plugin) to invalidate their cache for a particular page...

Yeah sure, there's the aforementioned "Block Visibility" plugin out there in the meantime, but it would be architecturally cleaner to have it as a built-in Gutenberg feature, and also it would be better for long-term viability instead of running into plugin problems

draganescu commented 1 year ago

I explored this a bit and it seeme achiveable by adding a system attribute (hidden) which causes the block edit to not render and the block render callback to skip the block via a render callback hook.

Skipping the rendering of the block edit keeps the block in the list view.

For static blocks we can use [getSaveElement](https://developer.wordpress.org/block-editor/reference-guides/filters/block-filters/#blocks-getsaveelement) to skip saving these hidden blocks.

krokodok commented 1 year ago

Love this idea! I think I would need it every week somehow. Really miss it in comparison to other CMS.

jarekmorawski commented 10 months ago

Yes, please! This would be a fantastic improvement that would enable a more flexible pattern/block design. For instance, in the product gallery pattern in Woo, we'd bundle a few extra blocks that may not necessarily be part of the basic design, like product name, ratings, share buttons, etc. To achieve this right now, we'd have to build a separate block and add extra visibility settings in the inspector.

Hiding blocks would simplify the structure (we'd rely on templates and template parts, not individual blocks) and help us surface different block configurations using more interesting/opinionated pattern layout variations.

richtabor commented 10 months ago

It could potentially be an option you turn on within editor preferences; as it's more of a builder flow than an everyday user flow.

Sirjazzfeetz commented 23 hours ago

WordCamp Presentation

All for hiding items on list "view", for granular view control.