Skip to content

Replace non-breaking spaces UI is confusing in 7.2-beta2 #85768

Closed

Description

@andreawetzel

Description

Testing WP 7.2-beta2, when a user is editing a paragraph with a non breaking space, there is a UI to convert this HTML entity into a regular space. This was added in #84737

The tooltip for the button reads "Replace non-breaking spaces" however, when clicked, it only converts the single non breaking space you are near to a regular space.

Updating to a singular "Replace non-breaking space" would be preferable if this UI only impacts one character at a time, though perhaps an option to clean up the whole paragraph at once would be another approach.

Step-by-step reproduction instructions

  1. Add a paragraph that contains a &nbsp via the code editor (example below)
  2. Switch to Visual editor
  3. Select the paragraph to edit it
  4. Place cursor next to red dot that indicates non-breaking space
  5. Observer the UI

Screenshots, screen recording, code snippet

Example paragraph

<!-- wp:paragraph -->
<p>Here is some text with <a href="#">some</a> <strong>bold</strong> and <em>italic</em> and some non-breaking &nbsp; spaces  that will appear as red dots when &nbsp; &nbsp; &nbsp; someone is &nbsp; editing this paragraph block. </p>
<!-- /wp:paragraph -->

Screenshot of tooltip
Image

Screencapture of conversion.

non-breaking-space-demo-2.mp4

Environment info

  • WP 7.2-beta2
  • Mac Chrome
  • Ipsum theme

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Activity

  1. added
    [Type] Bug
    on Oct 27, 2026
  2. added
    [Status] In Progress
    on Oct 27, 2026
  3. singhakanshu00 commented on Oct 27, 2026

    @singhakanshu00
    Contributor

    I looked into this, and the current behavior appears intentional: the action replaces non-breaking spaces within the current selection or adjacent to the caret, rather than throughout the paragraph.

    As suggested in the issue, I’ve addressed the misleading tooltip by updating packages/format-library/src/non-breaking-space/index.tsx to display “Replace non-breaking space” when only one non-breaking space will be replaced, and retain “Replace non-breaking spaces” when multiple spaces are affected. This keeps the existing replacement behavior unchanged while making the label more accurate.

    I’ve also added E2E tests in test/e2e/specs/editor/various/rich-text.spec.js to cover replacement at the caret and within a selection. The E2E tests are passing, except for a known flaky test on trunk in Firefox, which is unrelated to this change

  4. added
    [Feature] Rich Text
    on Oct 28, 2026
  5. hanneslsm commented on Oct 29, 2026

    @hanneslsm

    Related: #55565
    I'm a bit disappointed that the non-breaking spaces finds it's way faster into the editor than the very much need breaking words. But I'm very glad there is some traction, because both are extremely important.

    However, I'm also confused by the new UX, and I think a "replace" button is not a good behavior in the toolbar. We only have it once and I also don't like it there: #56385

    Anyway, instead of a "replace non-breaking changes" button in the toolbar that seems to pop up unpredictably, I suggest introducing a "break" button instead (or whatever a good name would be) that can be toggled off and on like bold or italic.
    The user either clicks on it between two words, then it replaces the space with a &nbsp; or within a word, then it'd enter a &shy; or <wbr />

  6. moved this from 🏗️ In Progress to ✅ Done in WordPress 7.2 Editor Taskson Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[Feature] Rich Text[Status] In Progress[Type] Bug

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions