-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Add support for custom label in archive dropdown #70492
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
base: trunk
Are you sure you want to change the base?
Add support for custom label in archive dropdown #70492
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes in this file seem unrelated to the PR 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed unrelated changes
| { showLabel && ( | ||
| <ToolsPanelItem | ||
| label={ __( 'Label' ) } | ||
| isShownByDefault | ||
| hasValue={ () => !! label } | ||
| onDeselect={ () => | ||
| setAttributes( { label: '' } ) | ||
| } | ||
| > | ||
| <TextControl | ||
| __nextHasNoMarginBottom | ||
| __next40pxDefaultSize | ||
| label={ __( 'Label' ) } | ||
| value={ label } | ||
| onChange={ ( value ) => | ||
| setAttributes( { label: value } ) | ||
| } | ||
| placeholder={ __( 'Archives' ) } | ||
| /> | ||
| </ToolsPanelItem> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having this control live in the Inspector I would much rather see the actual text label in the editor canvas use a RichText component to actually allow for inline editing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added RichText component in canvas
| }, | ||
| "label": { | ||
| "type": "string", | ||
| "default": "Archives" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot hard-code the default label here, as it is not translatable.
|
@fabiankaegy @t-hamano I've made the mentioned changes |
|
I've been researching this a bit more and have come across a few things to note.
|
Yes @t-hamano, I'll work on converting this block to dynamic block. |
It would be great if we could refactor it to just JS rendering. However, this might be technically quite difficult, as all of the logic in the Personally, I would like to propose thoroughly discussing the direction and approach in #57528. |
Fixes
What?
This PR makes the label above the Archives block dropdown editable by introducing a TextControl field in the block’s settings panel.
Why?
Currently, when the Archives block is set to display as a dropdown, there is an option to show a label above it. However, this label is hardcoded as "Archives" and cannot be customized by the user.
How?
Testing Instructions
Screenshots or screencast