Feature: [Enhancement] Site Editor Identity: consider live updates for the admin bar site icon and browser favicon after changing the Site Icon - #81501
Conversation
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
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.
Have worked on this here, Not sure is it the correct thing to change. As it's punted to 7.2 not sure if we are creating a new directory in compat and add the changes there?
What?
Closes #81483
Why?
site iconis updated, it needs reload to see the new icon in admin bar. Since admin bar is in our control, then change to site icon and on save should reflect it in admin bar.How?
useSyncAdminBarSiteIconin@wordpress/editorwhich refreshes the stale url and updates in admin bar to load the image with new URL.Testing Instructions
add_filter( 'wp_admin_bar_show_site_icons', '__return_false' );in place, confirm no icon appears at any point.Testing Instructions for Keyboard
Screenshots or screencast
Before
Screen.Recording.2026-08-13.at.2.00.39.PM.mov
After
Screen.Recording.2026-08-13.at.1.58.45.PM.mov
Use of AI Tools
AI Summary
What?
Closes #81483 (admin bar icon only)
Updates the site icon in the admin bar as soon as a new Site Icon is saved, instead of showing the old one until the page is reloaded.
Why?
The admin bar is rendered by PHP before the editor loads, so its icon is plain HTML sitting in the page with nothing to tell it a save happened.
There is also a data problem underneath. Saving writes
site_icon— an attachment ID — to the site settings, but the icon's URL lives on a different entity (root/__unstableBase, the REST index), and nothing refetches that entity after a save. So even a fully reactive component would have rendered the old URL.How?
A new hook,
useSyncAdminBarSiteIconin@wordpress/editor, doing two things:site_icon_urlis refetched.has-site-icon, which hides the fallback dashiconIt's mounted in two places, because the Site Icon can be changed from two separate apps: the Site Editor layout (Design → Identity, the flow in the issue) and the post editor's
EditorInitialization(the Site Logo block's "sync icon" toggle). There's no single component both editors always render.On the PHP side,
gutenberg_admin_bar_site_icon()now adds asupports-site-iconclass to the node whether or not an icon is set. This is the one thing the editor can't work out for itself: an unset icon and icons disabled via thewp_admin_bar_show_site_iconsfilter look identical in the markup. With the class, the hook knows whether it may show an icon at all — and does nothing when the filter is off. The icon markup itself is unchanged, still rendered only when an icon exists.