Skip to content

Preformatted: Scroll long lines instead of overflowing - #83873

Open
Mayank-Tripathi32 wants to merge 3 commits into
WordPress:trunkfrom
Mayank-Tripathi32:fix/70371-preformatted-overflow
Open

Mayank-Tripathi32 wants to merge 3 commits into
WordPress:trunkfrom
Mayank-Tripathi32:fix/70371-preformatted-overflow

Conversation

@Mayank-Tripathi32

@Mayank-Tripathi32 Mayank-Tripathi32 commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

What?

Closes #70371

Long unbroken lines (URLs, hashes, paths) in the Preformatted block now scroll inside the block instead of overflowing the content area on the front end.

Why?

A long string with no spaces pushes past the content width and makes the whole page scroll horizontally. In the issue, the suggestion was to apply horizontal scrolling to the Preformatted block by default.

How?

Adds overflow-x: auto to .wp-block-preformatted.

white-space: pre-wrap is kept on purpose: switching to pre would stop normal text with spaces (poems, prose) from wrapping and change existing content. With this change only lines that can't wrap get a scrollbar. The Verse block has used overflow: auto the same way for a long time.

One open question: the editor still wraps these lines, because of the shared overflow-wrap: break-word rule in block-editor/src/components/block-list/content.scss. Should Preformatted opt out of it in the editor so it matches the front end? Happy to add that here.

Related: #71585.

Testing Instructions

  1. Activate a block theme such as Twenty Twenty-Five.
  2. Add a Preformatted block and paste a long string with no spaces, e.g. https://example.com/ followed by ~150 characters.
  3. Add a second line with normal text and spaces.
  4. Publish and view the post.
  5. The long line scrolls inside the block; the page does not scroll horizontally. The normal text still wraps.

Testing Instructions for Keyboard

No UI changes. The scrollable block can be scrolled with the arrow keys once the text inside it is focused/selected.

Screenshots or screencast

Before After
image image

Use of AI Tools

I used Claude for investigation & testing.

Long unbroken strings such as URLs overflowed the content area on the
front end. Add overflow-x: auto so the block scrolls horizontally, as
agreed in WordPress#70371.
A front-end e2e is heavy for a one-line CSS change; before/after
screenshots in the PR cover it.
@github-actions github-actions Bot added the [Package] Block library /packages/block-library label Sep 30, 2026
@Mayank-Tripathi32 Mayank-Tripathi32 added the [Type] Enhancement A suggestion for improvement. label Sep 30, 2026
@Mayank-Tripathi32
Mayank-Tripathi32 marked this pull request as ready for review September 30, 2026 12:04
@github-actions

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: Mayank-Tripathi32 <mayanktripathi32@git.wordpress.org>

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

This branch has not been deployed

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

Labels

[Package] Block library /packages/block-library [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preformatted: Inconsistent behaviour across themes

1 participant