Revisions: Fix the classic revisions screen in a desktop window - #498
Merged
Conversation
Five fixes behind one report. The block editor's revisions sidebar links out with `target="_blank"`, which the chromeless bridge yielded on, so a same-origin wp-admin URL opened a raw browser tab. A `_blank` on an admin URL now opens a desktop window instead. Every other target still yields. The window took its name from the link's `textContent`, and Core's revisions link is a visible label plus a screen-reader one, so it came out "Browse Browse revisions". The label harvest skips `.screen-reader-text` and collapses whitespace, and a label the shell had to guess is replaced by the destination page's own screen name once the iframe loads. `setTitle()` wrote to a detached node. Layer 3's slot painter repaints each slot from `cloneNode` copies, so the span the constructor captured was already orphaned. Every window was in this state, which broke plugin `setTitle` and `os-title-change` too. "Go to editor" is hidden and the revision tooltip gets its clearance back, both page-scoped in chromeless.css. The tooltip is positioned upward from the control frame and only cleared the top of the viewport because of the screen H1 that chromeless hides. Restoring a revision is a `document.location` assignment, so WP's redirect turned the Revisions window into a second editor beside the stale one. A window opened on `revision.php` now closes when it leaves that screen and routes where it landed through the normal window-owns-a-slug rules. Fixes #491 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claiming a `_blank` admin link handed it to the parent's normal slug routing, which navigates the source iframe in place when the destination shares the window's slug. That destroys the one thing the `_blank` asked to keep. `deriveWindowId` treats `page` as identity but not `tab`, so any plugin screen linking `admin.php?page=x&tab=b` from `admin.php?page=x` hit it, and a `_blank` on a trash URL ran the destructive branch in place for the same reason. The bridge now claims a `_blank` only when the destination is a different wp-admin file, the one call it can make without the shell's slug rules, and flags the message `newContext` so the parent skips both in-place branches. Everything else opens a browser tab as before. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The slot painter restores each slot from a snapshot cloned at construction. Every other slot's default is fixed markup, but the title's is derived state, so restoring it verbatim put the window's original name back and left `config.title` reporting the new one. A repaint fires whenever the slot registry mutates, so activating a plugin that registers a window slot renamed every open window back to whatever it started as. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Cuts the walkthroughs down to what the next reader needs, drops the revision-specific examples from code that isn't revision-specific, and removes the compat-layer doc entry now that the CSS says it in three lines. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Fixes #491
Proposed changes
The path from the post editor to the classic revisions screen, fixed end to end:
<ExternalLink>, which hard-codestarget="_blank", and the bridge yielded on any target other than_self. A_blankon a/wp-admin/URL is now claimed like any other admin link._top,_parent, named targets and non-admin URLs still yield.textContent, and Core pairs a visible label with a screen-reader one. Screen-reader text is now dropped, and a name the shell had to guess is replaced by the page's own screen name on load.setTitle()repaints the title bar. It was writing to a node the slot painter had already replaced with a clone. Every window was in this state, so pluginsetTitleandos-title-changewere broken too.chromeless.css.Why are these changes being made?
Restoring a revision took you out of the shell and left you with two windows on the same post, one of them stale.
The restore is a
document.locationassignment inwp-admin/js/revisions.js, so no click reaches the bridge and WP's redirect lands wherever the frame is. The handoff is a named list (HANDOFF_SCREENS), not a general "crossing slugs hands off" rule, because the submenu tab strip re-points windows across slugs on purpose (Appearance → Menus).Testing instructions
With Classic Editor active (the block editor path is the same, the link just lives in the sidebar):
🤖 Generated with Claude Code