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

Block Registration: add SlotFill to extend a block's description #49887

Open
jeherve opened this issue Apr 18, 2023 · 7 comments · May be fixed by #66170
Open

Block Registration: add SlotFill to extend a block's description #49887

jeherve opened this issue Apr 18, 2023 · 7 comments · May be fixed by #66170
Labels
[Feature] Block API API that allows to express the block paradigm. [Feature] Extensibility The ability to extend blocks or the editing experience Good First Issue An issue that's suitable for someone looking to contribute for the first time Needs Dev Ready for, and needs developer efforts [Type] Bug An existing feature does not function as intended

Comments

@jeherve
Copy link
Contributor

jeherve commented Apr 18, 2023

What problem does this address?

It was previously possible to use React nodes in a block's description, like so:

description: (
		<Fragment>
			<p>
				{ __(
					'This block does something really fancy and complex.',
					'my-fancy-complex-block'
				) }
			</p>
			<p>
				{ __( 'Here is a detailed description about the things my block does.', 'my-fancy-complex-block' ) }
			</p>
			<ExternalLink href={ supportLink }>{ __( 'Learn more about how to use me', 'my-fancy-complex-block' ) }</ExternalLink>
		</Fragment>
	),

This allowed adding extra information to a block's description, such as links to support documentation or more.

Unfortunately, this is no longer encouraged since #44455.

What is your proposed solution?

Instead of adding all that information to the block's description itself, and since adding it there can have some unintended side-effects, it would be nice to add a new SlotFill that would be displayed right below the block's description in the editor sidebar, and nowhere else.

@gziolo gziolo added [Feature] Block API API that allows to express the block paradigm. Needs Dev Ready for, and needs developer efforts [Feature] Extensibility The ability to extend blocks or the editing experience labels Apr 18, 2023
@mtias
Copy link
Member

mtias commented May 31, 2023

@jeherve I'm curious if you'd expect this slot to be rendered wherever a block description is rendered. For example, in block previews in the inserter.

@jeherve
Copy link
Contributor Author

jeherve commented Jun 1, 2023

I would expect it to appear in the primary block sidebar only, not in the previews in the inserter. That's just me though. Maybe this could be a parameter?

@mtias
Copy link
Member

mtias commented Jun 1, 2023

So it might be good to contextualize the slot as InspectorBlockInfo or similar instead of something more generic. A parameter would be problematic on its own. it's not easy to anticipate all the contexts in which a description of a block might be rendered where the extender didn't expect.

@ndiego ndiego moved this from ❓ Triage to 🦵 Punted to 6.4 in WordPress 6.3.x Editor Tasks Jun 27, 2023
@bph bph moved this to ❓ Triage in WordPress 6.4 Editor Tasks Jul 25, 2023
@jordesign jordesign added the [Type] Bug An existing feature does not function as intended label Jul 26, 2023
@bph bph moved this from Triage to Punted to 6.5 in WordPress 6.4 Editor Tasks Sep 8, 2023
@bph bph moved this to ❓ Triage in WordPress 6.5 Editor Tasks Nov 23, 2023
@gziolo gziolo added the Good First Issue An issue that's suitable for someone looking to contribute for the first time label Jan 23, 2024
@bph bph moved this from Triage to Todo in Increase Gutenberg Extensibility Jan 23, 2024
@fabiankaegy
Copy link
Member

Since this ticket hasn't seen any progress since it was originally punted in the 6.3 release cycle, I'm going to talke it out of the release tracking borad. That doesn't mean that it couldn't go into a release if someone works on it. But since it isn't a major priority we don't need to track it in the release board.

@gziolo
Copy link
Member

gziolo commented Aug 20, 2024

There is a private slot fill that the Query block uses:

We should promote it to the public to resolve this issue.

@jarekmorawski
Copy link
Contributor

We have several use cases for such a feature in the WooCommerce blocks. For instance, we'd like to display a link that opens a feedback modal. I've seen a similar link in WordPress.com that opens each block's documentation page.

image

There's a risk that placing a slotfill in such a prominent location in the Inspector may lead to abuse and I wonder if we'd put some guardrails in place? For instance, we'd only allow links (with or without icons), but not buttons or notices.

@simison
Copy link
Member

simison commented Aug 20, 2024

Old proposal for API to add links in more declarative way, rather than an all-open slotFill:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Feature] Extensibility The ability to extend blocks or the editing experience Good First Issue An issue that's suitable for someone looking to contribute for the first time Needs Dev Ready for, and needs developer efforts [Type] Bug An existing feature does not function as intended
Projects
Development

Successfully merging a pull request may close this issue.

7 participants