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

Add method to name custom entity props #41637

Closed
richtabor opened this issue Jun 9, 2022 · 5 comments · Fixed by #59243
Closed

Add method to name custom entity props #41637

richtabor opened this issue Jun 9, 2022 · 5 comments · Fixed by #59243
Assignees
Labels
[Feature] Block API API that allows to express the block paradigm. [Feature] Extensibility The ability to extend blocks or the editing experience [Type] Feature New feature to highlight in changelogs.

Comments

@richtabor
Copy link
Member

What problem does this address?

When useEntityProp( 'root', 'site', 'title' ) is used, the entity is named "Title" within the confirmation step when saving changes.

Is there a method for naming custom entity props, to improve the UX of editing/saving them? Currently the option_name displays, instead of using a proper title, which makes it less clear what's actually being saved.

What is your proposed solution?

Have a method for assigning a name/title that displays when saving an entity prop, instead of the option_name.

Screenshots

Modifying the site title entity, displays as "Title"

CleanShot 2022-06-09 at 12 11 01@2x

Modifying a site option entity, displays the option_name

CleanShot 2022-06-09 at 12 07 18@2x

@adamziel
Copy link
Contributor

adamziel commented Jun 9, 2022

It looks like each Site property is listed separately in that sidebar:

for ( const property in siteEdits ) {
siteEditsAsEntities.push( {
kind: 'root',
name: 'site',
title: TRANSLATED_SITE_PROPERTIES[ property ] || property,
property,
} );
}

The culprit is that some properties use a human-readable label such as "Title", but the other ones are just passed verbatim, which is what you see. I wonder what a solution would look like, aside of course of allowing the developer to specify that 🤔

@adamziel
Copy link
Contributor

adamziel commented Jun 9, 2022

To document some thoughts from slack,

Rich said:

If I'm updating a site setting. Then having it say a human readable title would be better than the option name

To which Adam replied:

A larger list of hardcoded labels would be an easy step to making it better. Ideally it would cover all the site options shipped with core. Then, there are custom options provided by plugins, I guess plugins would have to provide these labels.

@adamziel
Copy link
Contributor

adamziel commented Jun 9, 2022

A minimal improvement would be adding more settings to this list:

const TRANSLATED_SITE_PROPERTIES = {
title: __( 'Title' ),
description: __( 'Tagline' ),
site_logo: __( 'Logo' ),
site_icon: __( 'Icon' ),
show_on_front: __( 'Show on front' ),
page_on_front: __( 'Page on front' ),
};

Then, to allow plugin authors to supply their own labels, we'd likely need to create a new filter and then apply it to that list using applyFilters from @wordpress/hooks. Perhaps around the following line?

title: TRANSLATED_SITE_PROPERTIES[ property ] || property,

@Thelmachido Thelmachido added [Feature] Block API API that allows to express the block paradigm. [Type] Feature New feature to highlight in changelogs. labels Jun 10, 2022
@Mamaduka
Copy link
Member

Maybe labels can be a part of the register_setting API. It currently supports the description argument. Then we'll need to figure out how to load this data for setting entities.

@mtias mtias added the [Feature] Extensibility The ability to extend blocks or the editing experience label Jun 25, 2022
@ghost
Copy link

ghost commented Nov 3, 2022

Subscribed. Would really like to see this feature in an upcoming update.

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Nov 19, 2022
@Mamaduka Mamaduka self-assigned this Feb 27, 2024
@Mamaduka Mamaduka removed the [Status] In Progress Tracking issues with work in progress label Mar 21, 2024
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 [Type] Feature New feature to highlight in changelogs.
Projects
5 participants