Add support for custom label in archive dropdown#70492
Add support for custom label in archive dropdown#70492dhananjaykuber wants to merge 2 commits intoWordPress:trunkfrom
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.
These changes in this file seem unrelated to the PR 🤔
There was a problem hiding this comment.
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.
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.
Added RichText component in canvas
| }, | ||
| "label": { | ||
| "type": "string", | ||
| "default": "Archives" |
There was a problem hiding this comment.
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