#66222 closed defect (bug) (fixed)
Toolbar: live-preview of unsaved display name change is not accurate
| Reported by: | fushar | Owned by: | mcsf |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.2 |
| Component: | Toolbar | Version: | 6.5 |
| Severity: | normal | Keywords: | has-patch has-screenshots |
| Cc: | Focuses: | accessibility, javascript |
Description
On wp-admin/profile.php, whenever we update the display name, the my-account node and its dropdown is supposed to be live-previewed. However, there are a few bugs:
- The
Edit Profileitem also gets overwritten with the display name. - The account submenu's
aria-labelis not updated with the new display name. - The username line doesn't respond to the change. For example, if the new display name is no longer the same as the username, the dropdown does not show the username.
Attachments (4)
Change History (14)
This ticket was mentioned in PR #13881 on WordPress/wordpress-develop by @hbhalodia.
7 weeks ago
#1
- Keywords has-patch added
Trac ticket: https://core.trac.wordpress.org/ticket/66222
What
Fixes the toolbar account menu not updating correctly when you change the display name on wp-admin/profile.php, before saving.
Why
The live preview used one broad .display-name selector, which caused three bugs:
- "Edit Profile" in the dropdown was replaced with the display name.
- The submenu's
aria-labelstill showed the old name. - The username line didn't show or hide when the display name changed.
How
- Target the "Howdy" greeting and the dropdown name separately, skipping
.edit-profile. - Update the
aria-labelon#wp-admin-bar-user-actionsusing the same translatableHowdy, %sstring. - Show the username line only when it differs from the display name, as the PHP output does.
Testing
- Log in as a user whose display name matches their username (e.g.
admin). - Go to Users → Profile, enter a First Name, and select it in Display name publicly as. Don't save.
- Hover over the account menu in the toolbar and check that:
- "Edit Profile" is still shown.
- The username appears below the new display name.
ul#wp-admin-bar-user-actionshasaria-label="Howdy, <new name>".
- Switch the display name back to the username. The username line should go away.
- Edit another user's profile (
user-edit.php). The toolbar should not change.
Use of AI Tools
- Claude Code, Opus 5.5
- Used for PR description, reproduction steps, and implementation.
- It was reviwed by me.
#2
@
7 weeks ago
- Keywords has-screenshots added
Good catch. I took the liberty to prepare another screenshot to better explain the inconsistencies (there may be more flows that trigger more ones though). See screenshot below:
- Initial state, with 'Display name publicly as' set to 'admin'.
- 'Display name publicly as' changed to first and last name, live preview.
- After saving and page reload.
#3
@
6 weeks ago
Test Report
Description
This report validates that the indicated patch works as expected.
Patch tested: https://github.com/WordPress/wordpress-develop/pull/13881 (head 6bc7e75)
Environment
- WordPress: 7.2-alpha-63166-src (trunk
f4350cd9e2;user-profile.js,admin-bar.phpandclass-wp-admin-bar.phpare unchanged on the current trunkdcd149a95c) - PHP: 8.3.33
- Server: nginx (macOS, arm64)
- Database: MySQL 9.2.0
- Browser: Chromium (Playwright, headless),
SCRIPT_DEBUGenabled - Theme: Twenty Twenty-Five 1.5
- Plugins: none
Steps taken
- Created an administrator
tester66222with first nameJane, last nameDoe, nicknameJD, display nametester66222(same as the login). - On
wp-admin/profile.php, changed "Display name publicly as" and recorded the toolbar before saving (live preview): the "Howdy" name, the name in the dropdown, the username line, the "Edit Profile" label, thearia-labelof#wp-admin-bar-user-actions, and the order of the spans. - Clicked Update Profile and recorded the same values from the server-rendered toolbar after the reload.
- Compared live vs. saved for each scenario, on trunk and then with the PR applied.
Scenarios:
| # | Change | What it checks |
|---|---|---|
| S1 | login → Jane Doe | username line must be added |
| S2 | Jane Doe → JD | username line kept |
| S3 | JD → login | username line must be removed |
| S4 | Jane → login → Doe Jane before saving | remove, then re-add, in one session |
| S5 | Doe Jane → login | removal again |
| S6 | type first name Tom & Jerry, pick it | option created live, special characters |
| S7 | on user-edit.php?user_id=1, pick another name (not saved) | another user's profile must not change the toolbar |
Actual Results
Trunk: ❌ bug reproduced (S1–S6 fail, S7 passes)
- The "Edit Profile" label in the dropdown is replaced with the display name. Trunk's
.find( '.display-name' )also matches<span class="display-name edit-profile">. - The username line is never added or removed, so the dropdown keeps the old state until reload.
- The
aria-labelof the account menu (Howdy, …) keeps the old name.
Example (S1, login → Jane Doe):
| Field | Live preview (trunk) | After save |
|---|---|---|
| Dropdown lines | Jane Doe / Jane Doe | Jane Doe / tester66222 / Edit Profile
|
| Username line | missing | tester66222
|
| "Edit Profile" label | Jane Doe | Edit Profile
|
Menu aria-label | Howdy, tester66222 | Howdy, Jane Doe
|
With PR #13881: ✅ all scenarios pass
- In S1–S6 the live preview matches the saved toolbar for every field: greeting, dropdown name, username line (added, kept, removed, and re-added in the right position), "Edit Profile" label, and menu
aria-label. - S7: editing another user's profile does not change the toolbar.
- No JavaScript errors from the patched code.
Additional Notes
- The new
__( 'Howdy, %s' )in JS is the same string as the server-side greeting, anduser-profilealready callsset_translations(). Translated sites should therefore get a matching label. - The username check mirrors the server's
display_name !== user_logincomparison inwp_admin_bar_my_account_menu(). - One trunk run hit an intermittent
Cannot read properties of undefined (reading 'serialize')from the existing unsaved-changes handler (user-profile.js,$form.serialize()) while the browser was closing. It didn't happen on re-runs and is in code this PR doesn't touch. - I didn't test the case afercia mentioned where other flows may cause more mismatches, beyond the 7 scenarios above. If there are specific flows in mind, I'm happy to test them.
Use of AI Tools
AI assistance: Yes
Tool(s): Antigravity
Used for: Writing the Playwright script that compares the live and saved toolbar, running it, and drafting this report. I reviewed the results and screenshots.
This ticket was mentioned in PR #14275 on WordPress/wordpress-develop by @fushar.
5 weeks ago
#4
Trac ticket: https://core.trac.wordpress.org/ticket/66222
Summary
This PR contains two follow-ups to moving "Howdy" into the user menu (https://github.com/WordPress/wordpress-develop/pull/13681). The fixes are very closely related so I'm making both changes in this single PR.
- "Howdy" color: I just found out that some custom plugins' admin color schemes only color
#wp-admin-bar-user-info .display-namein their CSS, so the display name gets the scheme's color but the "Howdy, " text doesn't. This PR adds thedisplay-nameclass to the greeting wrapper (<span class="display-name howdy">).- Note that that same class was also added to the
Edit Profilelink for the same reason (see https://core.trac.wordpress.org/changeset/57765).
- Note that that same class was also added to the
- Display name live preview: when the display name dropdown is changed on the profile page, the admin bar is live-updated. This PR fixes the bugs mentioned in the linked Trac ticket, so that now:
- The "Edit Profile" item is no longer overwritten.
- The
aria-labelof the user menu is now updated with the new display name. - The username line now reacts to the change. For example, if the new display name is no longer the same as the username, the menu won't show the username line.
Testing
- Activate an admin color scheme that only colors
.display-namein the CSS. The easiest way is to install theAdmin Color Schemesplugin. - Hover the avatar menu, and verify that the whole
Howdy, {name}greeting has the same text color. - Go to Users -> Profile, and change the "Display name publicly as" field. Don't save.
- Verify that the display name in the admin bar and in the dropdown is live-updated, and that "Edit Profile" stays the same.
- Select your username as the display name, and verify that the username line below the greeting disappears. Select another name, and verify that it appears again.
- Inspect the user menu (
#wp-admin-bar-user-actions), and verify that itsaria-labelmatches the selected display name.
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus 5.5
Used for: Code generation. Verified and tested by me.
#8
follow-up:
↓ 9
@
4 weeks ago
Hi @mcsf, Sorry but I guess you might have missed some props giving here to @therssoftware for testing the PRs that were attached to the ticket. Also to the PR authors :)
Thanks,
#9
in reply to: ↑ 8
@
4 weeks ago
Replying to hbhalodia:
Hi @mcsf, Sorry but I guess you might have missed some props giving here to @therssoftware for testing the PRs that were attached to the ticket
I'll be very honest: I seriously question the props-worthiness of these automated and verbose "test reports".
Also to the PR authors :)
The changeset is based on https://github.com/WordPress/wordpress-develop/pull/14275, for which the author and reviewer were indeed attributed. Though I appreciate your willingness to contribute, https://github.com/WordPress/wordpress-develop/pull/13881 didn't materialise into a patch with reviewer validation, and so props may or may not be due.
That said, I do concede that it's easy to miss props in our hybrid Trac-GitHub setup. @desrosj, do you know if there's ever been a discussion about making the GitHub props bot also consider participants in the original Trac ticket?


screenshot of the broken live preview