Skip to content

Administration: Limit page jumping by scoping admin notice relocation - #13218

Open
wprashed wants to merge 1 commit into
WordPress:trunkfrom
wprashed:fix/65877-limit-page-jump-admin-notices
Open

Administration: Limit page jumping by scoping admin notice relocation#13218
wprashed wants to merge 1 commit into
WordPress:trunkfrom
wprashed:fix/65877-limit-page-jump-admin-notices

Conversation

@wprashed

Copy link
Copy Markdown

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-end previously used an un-scoped selector:

.not('.inline, .below-h2').insertAfter();

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 like edit.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:

    .not('.inline, .below-h2')
    .insertAfter();
  • Only moves top-level notices that were rendered before .wrap by admin-header.php's admin_notices action hook.
  • Preserves notices already positioned within .wrap or specific sub-containers, preventing redundant DOM repositioning and mitigating layout shift.

Fixes #65877.

… 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.
@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props wprashed, sadmansakibnadvi.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@sadmansakibnadvi

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants