Skip to content

Visual revisions: Add a code diff view inside the editor - #80314

Open
priethor wants to merge 8 commits into
trunkfrom
priethor/check-visual-revisions
Open

Visual revisions: Add a code diff view inside the editor#80314
priethor wants to merge 8 commits into
trunkfrom
priethor/check-visual-revisions

Conversation

@priethor

@priethor priethor commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

What

Closes #77841, part of #79120.

Adds a Code editor option to the block editor revisions screen, showing the selected revision's raw markup and highlighting the lines that were added or removed. The Show changes toggle on the top left switches between the diff and the plain markup.

Why

A visual diff can miss changes to block attributes when the rendered post still looks the same. The code view makes those changes visible in the new revisions screen instead of sending users back to the classic one.

Testing Instructions

  1. Create a post and save two revisions with different paragraph content.
  2. Open Revisions from the Post sidebar.
  3. Open Options and choose Code editor.
  4. Check that the old and new markup are highlighted, then move the slider and confirm the diff updates.
  5. Turn off Show changes and confirm that only the selected revision's markup is shown.
  6. Exit revisions while the Code editor is selected and confirm that the post editor remains in code mode.
  7. Switch back to the Visual editor and confirm that revisions return to the visual view.
  8. With network throttling enabled, reopen Revisions and open Options before the slider finishes loading. Confirm that the focus does not jump to the slider.

Screen recording

Grabacion.de.pantalla.2026-07-15.a.las.15.44.12.mov

I used Codex to implement these changes. I guided the work, tested it, and reviewed the results.

@priethor priethor self-assigned this Jul 15, 2026
@priethor priethor added [Type] Enhancement A suggestion for improvement. [Feature] History History, undo, redo, revisions, autosave. labels Jul 15, 2026
@github-actions github-actions Bot added the [Package] Editor /packages/editor label Jul 15, 2026
@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

Size Change: +2.4 kB (+0.03%)

Total Size: 7.76 MB

📦 View Changed
Filename Size Change
build/scripts/editor/index.min.js 500 kB +1.04 kB (+0.21%)
build/styles/editor/style-rtl.css 31.4 kB +352 B (+1.13%)
build/styles/editor/style-rtl.min.css 26.7 kB +329 B (+1.25%)
build/styles/editor/style.css 31.4 kB +349 B (+1.12%)
build/styles/editor/style.min.css 26.7 kB +330 B (+1.25%)

compressed-size-action

@priethor
priethor force-pushed the priethor/check-visual-revisions branch from 6273318 to 416f1ac Compare July 15, 2026 13:42
@priethor
priethor marked this pull request as ready for review July 15, 2026 13:45
@github-actions

github-actions Bot commented Jul 15, 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.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: priethor <priethor@git.wordpress.org>
Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: himanshupathak95 <abcd95@git.wordpress.org>
Co-authored-by: simison <simison@git.wordpress.org>

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

@priethor
priethor requested a review from ellatrix July 16, 2026 15:15
@priethor
priethor force-pushed the priethor/check-visual-revisions branch from 416f1ac to aa7aefd Compare July 16, 2026 15:19
@github-actions

Copy link
Copy Markdown

Flaky tests detected in aa7aefd.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/29510630171
📝 Reported issues:

@priethor
priethor force-pushed the priethor/check-visual-revisions branch from aa7aefd to 119821e Compare July 20, 2026 09:27
@priethor
priethor force-pushed the priethor/check-visual-revisions branch from 454e67c to cd34da9 Compare July 27, 2026 15:08
revision: getCurrentRevision(),
previousRevision: _previousRevision,
showDiff: _showDiff,
isPreviousRevisionLoading:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the request for the next revisions page fails, the core-data resolver swallows the error, getPreviousRevision keeps returning null, and this condition stays true forever, so the code view shows the spinner indefinitely (turning off "Show changes" is the only way out). I think instead of inferring the loading state from null we should check the resolution status, e.g. hasFinishedResolution( 'getRevisions', … ) on core-data, and fall back to showing the revision without the diff when the previous revision cannot be loaded.


// If the user moves focus while revisions load, keep it there when the
// slider mounts.
if ( ! didInteractWhileLoadingRef.current && focusHasNotMoved ) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didInteractWhileLoadingRefis set on any keydown and never reset, so a key press that does not move focus (e.g. Escape while the spinner is showing) permanently skips the slider focus and keyboard focus is left on the body. SincefocusHasNotMoved` already covers the "user moved focus" case, do we need the interaction flag at all? Could we simplify the code and remove it?


- The "Apply globally" control now opens a review modal so you can choose which of a block's modified styles are pushed to Global Styles, showing each style's current and new value ([#79839](https://github.com/WordPress/gutenberg/pull/79839)).

### Enhancements

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are duplicating the ### Enhancements section, we should add the log on the existing one.

@jorgefilipecosta jorgefilipecosta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments but things look good and I think it could be merged after the comments are addressed/answred.

/**
* Internal dependencies
*/
import { RevisionsCodeDiff, getCodeDiffRows } from '../revisions-code-diff';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we use for the classic revisions screen? Are we using the same thing?

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

Labels

[Feature] History History, undo, redo, revisions, autosave. [Package] Editor /packages/editor [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Visual revisions: offer seamless code-diff mode

3 participants