Administration: Limit page jumping by scoping admin notice relocation - #13218
Administration: Limit page jumping by scoping admin notice relocation#13218wprashed wants to merge 1 commit into
Conversation
… to direct children of #wpbody-content.
In `common.js`, `$('div.updated, div.error, div.notice')` was un-scoped,
selecting all notices anywhere on the page (including inside `.wrap`,
list tables, metaboxes, and contextual areas) and moving them to
`.wp-header-end`. This caused unnecessary DOM manipulation, re-ordering,
and unexpected layout shift (page jumps) on overview pages such as `edit.php`.
This scopes the selector to only move notices that are direct children of
`#wpbody-content` (i.e. those output before `.wrap` by `admin-header.php`),
leaving in-page and table notices intact in their authored positions.
Fixes #65877.
See #45186.
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
Tested this on the Playground build for the PR with a small test plugin (a notice nested inside a settings panel plus a normal admin_notices notice) and posted a full test report including the plugin code on the ticket. Short version: the nested notice now keeps its position inside the panel, and top-level admin notices still relocate under the page heading exactly as before. |
Trac Ticket
https://core.trac.wordpress.org/ticket/65877
See also https://core.trac.wordpress.org/ticket/45186
Description
In
src/js/_enqueues/admin/common.js, notice relocation after.wp-header-endpreviously used an un-scoped selector:This matched and moved every notice found anywhere in the DOM—including contextual notices rendered inside
.wrap, list tables, metaboxes, or forms—ripping them out of their authored positions and re-inserting them under.wp-header-end. On pages likeedit.php, this resulted in unnecessary DOM mutation, reverse ordering, and sudden layout shifts (page jumping) as the user interacts with the post list.The Fix
Scopes the selector to only move notices that are direct children of
#wpbody-content:.wrapbyadmin-header.php'sadmin_noticesaction hook..wrapor specific sub-containers, preventing redundant DOM repositioning and mitigating layout shift.Fixes #65877.