feat[my-account-block]: add option to toggle off icon/text, and update tests#4443
Open
laurelfulford wants to merge 6 commits intotrunkfrom
Open
feat[my-account-block]: add option to toggle off icon/text, and update tests#4443laurelfulford wants to merge 6 commits intotrunkfrom
laurelfulford wants to merge 6 commits intotrunkfrom
Conversation
6 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds display controls to the My Account Button block, allowing users to selectively hide either the icon or label text, while ensuring at least one element remains visible for usability. The PR also improves the empty label fallback behavior and fixes an issue where logged-in admins were seeing incorrect button labels.
Changes:
- Added
showLabelandshowIconboolean attributes with UI toggles in the Inspector Controls - Updated empty label handling to fallback to defaults instead of rendering nothing
- Added
data-wp-logged-inattribute to preserve correct labels for logged-in WordPress users - Updated tests to verify fallback behavior for empty labels
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/blocks/my-account-button/block.json | Added showLabel and showIcon boolean attributes with default values of true |
| src/blocks/my-account-button/edit.js | Implemented Inspector Controls with toggle controls and mutual exclusivity logic, added conditional rendering for icon/label visibility |
| src/blocks/my-account-button/class-my-account-button-block.php | Added showLabel/showIcon attribute handling, conditional rendering logic, screen-reader-text class for hidden labels, and data-wp-logged-in attribute |
| src/reader-activation-auth/index.js | Added check for logged-in WordPress users to preserve correct label text and prevent unnecessary reader authentication checks |
| tests/unit-tests/class-test-my-account-button-block.php | Split empty label test into separate signed-in/signed-out tests, updated assertions to verify fallback to default labels |
| src/blocks/my-account-button/README.md | Added documentation for the new Display toggle feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
6 tasks
8d2f75a to
666a61a
Compare
666a61a to
d315db9
Compare
Contributor
|
Here's an update, using styles: d315db9
|
Contributor
Author
|
@thomasguillot Looks good to me! 🙂 Now we just need to see what an uninvolved third-party has to say! |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

All Submissions:
Changes proposed in this Pull Request:
This PR adds an option to hide either the icon or label on the My Account Button block (but not both at the same time).
As part of that, I changed how the button acts if you don't give it a text label (instead of not showing anything, it will fallback to the default labels) -- when it's hidden in the settings, the label is still used as screen reader text so we don't want it to be empty even if it's not visible.
I also updated the tests to check for the default (vs. making sure empty strings were empty), and tweaked the behaviour to make sure logged in admins (not just readers) would see the My Account labels - I thought this was working before but I was seeing Sign In in trunk.
See NPPD-1183.
How to test the changes in this Pull Request:
npm run build. As a bonus you can also test this alongside feat: make My Account button only show icon on mobile newspack-block-theme#406, but it's not required.screen-reader-textspan.Other information: