Repository navigation
feat: add icon-only button position #9
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
Merged
rsanchez-beapi
merged 9 commits into
BeAPI:develop
from
rsanchez-beapi:feature/button-icon-only
Nov 25, 2026
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
548bf83
chore: add plugin-data
firestar300 9a95d9f
Merge pull request #4 from BeAPI/chore/plugin-data
firestar300 cc78cab
Revert "chore: add plugin-data"
firestar300 585b8f7
Merge pull request #5 from BeAPI/revert-4-chore/plugin-data
firestar300 568f923
Merge pull request #8 from BeAPI/release/1.0.0
firestar300 834fc58
feat: add icon-only button position
rsanchez-beapi 29fe793
fix: improve icon-only button functionality and accessibility
rsanchez-beapi b497aa3
fix(a11y): keep icon name when button label is empty
rsanchez-beapi a64ef93
fix(editor): keep icon clickable in icon-only mode
rsanchez-beapi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
languages/blockparty-button-icon-fr_FR-dfbff627e6c248bcb3b61d7d06da9ca9.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| {"translation-revision-date":"2026-10-15 22:34+0200","generator":"WP-CLI\/2.11.0","source":"build\/index.js","domain":"messages","locale_data":{"messages":{"":{"domain":"messages","lang":"fr_FR","plural-forms":"nplurals=2; plural=(n != 1);"},"Remove icon":["Retirer l\u2019ic\u00f4ne"],"Icon":["Ic\u00f4ne"],"Show icon":["Afficher l\u2019ic\u00f4ne"],"Icon position":["Position de l\u2019ic\u00f4ne"],"Left":["Gauche"],"Right":["Droite"],"Replace Icon":["Remplacer l\u2019ic\u00f4ne"],"Mark as nofollow":["Marquer en nofollow"],"Button text":["Texte du bouton"],"Add text\u2026":["Ajouter du texte\u2026"],"Link":["Lien"]}}} | ||
| {"translation-revision-date":"2026-10-15 22:34+0200","generator":"WP-CLI\/2.12.0","source":"build\/index.js","domain":"messages","locale_data":{"messages":{"":{"domain":"messages","lang":"fr_FR","plural-forms":"nplurals=2; plural=(n != 1);"},"Remove icon":["Retirer l\u2019ic\u00f4ne"],"Icon":["Ic\u00f4ne"],"Show icon":["Afficher l\u2019ic\u00f4ne"],"Icon position":["Position de l\u2019ic\u00f4ne"],"Left":["Gauche"],"Right":["Droite"],"Replace Icon":["Remplacer l\u2019ic\u00f4ne"],"Mark as nofollow":["Marquer en nofollow"],"Button text":["Texte du bouton"],"Add text\u2026":["Ajouter du texte\u2026"],"Link":["Lien"],"Icon only":["Ic\u00f4ne seule"],"Label (screen readers)":["Libell\u00e9 (lecteurs d\u2019\u00e9cran)"],"Required. Hidden on screen, announced by assistive technologies.":["Obligatoire. Masqu\u00e9 \u00e0 l\u2019\u00e9cran, annonc\u00e9 par les technologies d\u2019assistance."],"A label is required for an icon-only button to be accessible.":["Un libell\u00e9 est obligatoire pour qu\u2019un bouton ic\u00f4ne seule soit accessible."],"Inside a button, this icon is decorative: the button label is its accessible name. The icon alternative text is only used when the button label is empty.":["Dans un bouton, cette ic\u00f4ne est d\u00e9corative : le libell\u00e9 du bouton sert de nom accessible. Le texte alternatif de l\u2019ic\u00f4ne n\u2019est utilis\u00e9 que si le libell\u00e9 du bouton est vide."]}}} |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /** | ||
| * Converts the button rich-text label to plain text (for a TextControl). | ||
| * | ||
| * Uses DOMParser so the markup is parsed in an inert document (no script or | ||
| * resource loading). | ||
| * | ||
| * @param {string|undefined} html Rich-text HTML. | ||
| * @return {string} Plain text. | ||
| */ | ||
| export function getButtonLabelPlainText( html ) { | ||
| if ( ! html ) { | ||
| return ''; | ||
| } | ||
|
|
||
| const doc = new window.DOMParser().parseFromString( | ||
| `<body>${ html }</body>`, | ||
| 'text/html' | ||
| ); | ||
|
|
||
| return doc.body.textContent || ''; | ||
| } | ||
|
|
||
| /** | ||
| * Escapes plain text so it can be stored in the rich-text `text` attribute. | ||
| * | ||
| * @param {string} text Plain text typed by the editor. | ||
| * @return {string} HTML-safe text. | ||
| */ | ||
| export function plainTextToButtonLabel( text ) { | ||
| return ( text || '' ) | ||
| .replace( /&/g, '&' ) | ||
| .replace( /</g, '<' ) | ||
| .replace( />/g, '>' ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Régression sur les boutons v1.0.0 sans libellé
Ce filtre tourne au rendu, donc sur tout le contenu déjà publié, sans réenregistrement. Un bouton v1.0.0 avec icône + libellé vide +
aria-labelsur l'icône (le seul moyen de faire une icône seule avant cette PR) devient un lien sans nom accessible.Suggestion : ne poser
aria-hiddenque si le libellé a du texte. Le plus simple est probablement de le faire dansleave_button_with_icon_context()(le filtrerender_block_core/button), où tu as le HTML complet du bouton : tu vérifies que.wp-block-button__labeln'est pas vide (par exemple avectrim( wp_strip_all_tags( … ) )sur le contenu du span, ou avecWP_HTML_Processor), puis tu posesaria-hiddensur.wp-block-icon. Sinon, tu laisses l'icône telle quelle. Ça règle aussi le cas « icône seule + libellé vide » (point 3 de la review).Un test PHPUnit sur ce cas serait bienvenu.
Generated by Claude Code
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.
Corrigé dans b497aa3. Le
aria-hiddenn'est plus posé dansrender_icon_as_span()mais dansleave_button_with_icon_context(), sur le HTML complet du bouton, et seulement si.wp-block-button__labelcontient du texte (button_label_has_text(), viaWP_HTML_Tag_Processor, gère les<span lang>imbriqués et les ). Un bouton v1.0.0 avec libellé vide garde donc l'aria-labelde son icône. Couvert par des tests PHPUnit (data provider) et un test E2E front.