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

Generate Unique IDs or Classes on Gutenberg Components #12067

Open
mrwweb opened this issue Nov 19, 2018 · 1 comment
Open

Generate Unique IDs or Classes on Gutenberg Components #12067

mrwweb opened this issue Nov 19, 2018 · 1 comment
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience [Type] Enhancement A suggestion for improvement.

Comments

@mrwweb
Copy link

mrwweb commented Nov 19, 2018

Is your feature request related to a problem? Please describe.
I see this was requested before in #6507, but I think it may be worth reconsidering. I'd ask that Components each get a unique ID to allow for more targeted styling, JS, etc. If I understand it right, it seems this is also causing issues in e2e testing (#7974).

The original ticket was closed for the following reason:

We want to encourage the ecosystem to move away from using CSS selectors to achieve these kind of effects in favor of filters and slots, as they are a lot more robust and portable across platforms (like Mobile), which is going to be one of the targets of the editor in the coming months. Using ids as a way to disable features is going to quickly start falling apart for the developer, and would couple us with the DOM structure.

However, at the moment, the various ways to disable features seem to be lacking, so this is out only option. Right now, I'm updating a plugin that will be hiding the dropcap option. Since there's no way to programmatically do that and there isn't a unique ID or class, I'm going with a I-hope-this-doesn't-hide-anything-else approach:

/* disable Dropcap. Currently no API to do it... */
.components-panel__body.blocks-font-size .components-toggle-control:nth-child(3) {
	display: none;
}

Describe the solution you'd like
More unique IDs and classes to enable e2e tests and give developers the hooks they need for functions not provided by an API. It's neither possible nor desirable to make an API to do every possible thing a developer might want, so this feels like a very reasonable solution.

Describe alternatives you've considered
As best I can tell, there is no alternative for what I'm trying to do. In many cases (like styling a component), there is no alternative other than selectors that will be prone to breaking or selecting more than intended. Even if this may encourage some less-than-ideal behavior, the alternative feels worse.

@catehstn catehstn added the [Type] Enhancement A suggestion for improvement. label Nov 19, 2018
@designsimply designsimply added the [Feature] Extensibility The ability to extend blocks or the editing experience label Nov 19, 2018
@talldan
Copy link
Contributor

talldan commented Dec 14, 2020

#27684 mentioned a desire for a classname/id on the row containing the post author dropdown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

4 participants