Skip to content

Fix: Fixes non-breaking space replacement tooltip - #85777

Merged
ellatrix merged 4 commits into
WordPress:trunkfrom
singhakanshu00:fix/non-breaking-space-tooltip
Oct 29, 2026
Merged

ellatrix merged 4 commits into
WordPress:trunkfrom
singhakanshu00:fix/non-breaking-space-tooltip

Conversation

@singhakanshu00

@singhakanshu00 singhakanshu00 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

What?

See #85768

Makes the label of the "Replace non-breaking spaces" toolbar button match how many non-breaking spaces it replaces: "Replace non-breaking space" for one, "Replace non-breaking spaces" for more than one.

Why?

The button added in #84737 is always labelled "Replace non-breaking spaces", but it only replaces the non-breaking spaces in the selection, or on either side of the caret. In the most common case, the caret next to a single non-breaking space, the plural label suggests every non-breaking space in the paragraph will be replaced, when only that one is.

How?

The replacement scope from #84737 is deliberate and unchanged: the code comment describes it as "the selected text, or the characters on both sides of the caret", and its e2e test asserts that a non-breaking space outside the selection is kept. Replacing every non-breaking space in the paragraph would also be destructive, since they are often intentional (10 km, French « »).

Instead, the edit function counts the non-breaking spaces in the same range the button replaces, and picks the label from that count. Following the convention for labels that don't show the number (for example in block-switcher), it uses two __() strings instead of _n(). The existing plural string is unchanged, so no existing translation is lost; there is one new string.

Tests, in test/e2e/specs/editor/various/rich-text.spec.js:

  • The existing test now expects the singular label, since every step in it involves one non-breaking space. Its locators use exact: true, because Playwright matches accessible names by substring and the singular name would otherwise also match the plural one.
  • Two new tests cover the plural label: the caret between two non-breaking spaces, and a selection containing two (checking that one outside the selection is kept).

Added a Bug Fixes entry to the @wordpress/format-library changelog, since the button shipped in 6.0.0.

Known flaky test (not changed here)

The existing test should replace selected non-breaking spaces from the toolbar is flaky in Firefox on trunk locally on macOS (2 of 10 runs locally, with the trunk build): keystrokes typed right after insertBlock() are sometimes lost before the paragraph has focus.

Testing Instructions

  1. Open a post and add a Paragraph block.
  2. Type one, then press Cmd+Shift+Space (Ctrl+Shift+Space on Windows) to insert a non-breaking space.
  3. Hover the highlighted button in the block toolbar: it reads "Replace non-breaking space". Click it and confirm only that one is replaced.
  4. Press Cmd+Shift+Space twice, then put the caret between the two non-breaking spaces. The button reads "Replace non-breaking spaces"; clicking it replaces both.
  5. Select some text containing two or more non-breaking spaces. The button reads "Replace non-breaking spaces"; clicking it replaces those in the selection only.
  6. Select text containing exactly one: the button reads "Replace non-breaking space".

Testing Instructions for Keyboard

  1. With the caret next to a single non-breaking space, press Alt+F10 to move focus to the block toolbar.
  2. Move to the button with the arrow keys and confirm its accessible name (announced by a screen reader, and shown as its tooltip) is "Replace non-breaking space".
  3. Repeat with the caret between two non-breaking spaces and confirm the name is "Replace non-breaking spaces". Press Enter and confirm both are replaced.

Screenshots or screencast

Screen.Recording.2026-10-28.at.12.46.58.AM.mov

Use of AI Tools

I used Claude Code to investigate the behaviour, assist in writing the e2e tests and draft this description. I reviewed the changes and ran the lint, type check, and e2e checks myself, including the trunk comparison for the flaky test.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

🎉 Props

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: singhakanshu00 <akanshusingh@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: andreawetzel <awetz583@git.wordpress.org>

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

@github-actions github-actions Bot added the [Package] Format library /packages/format-library label Oct 27, 2026
The selection case is already covered by the existing test, and setting
the paragraph content directly avoids typing before the block has focus.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ellatrix ellatrix added the [Type] Bug An existing feature does not function as intended label Oct 29, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ellatrix
ellatrix merged commit 4422fc7 into WordPress:trunk Oct 29, 2026
89 of 90 checks passed
@github-actions github-actions Bot added this to the Gutenberg 24.4 milestone Oct 29, 2026
@ellatrix ellatrix added the Backport to WP 7.2 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

There was a conflict while trying to cherry-pick the commit to the wp/7.2 branch. Please resolve the conflict manually and create a PR to the wp/7.2 branch.

PRs to wp/7.2 are similar to PRs to trunk, but you should base your PR on the wp/7.2 branch instead of trunk.

# Checkout the wp/7.2 branch instead of trunk.
git checkout wp/7.2

# Create a new branch for your PR.
git checkout -b my-branch

# Cherry-pick the commit.
git cherry-pick 4422fc73daff6d2eee3094403729989827d5817f

# Check which files have conflicts.
git status

# Resolve the conflict...
# Add the resolved files to the staging area.
git status
git add .
git cherry-pick --continue

# Push the branch to the repository
git push origin my-branch

# Create a PR and set the base to the wp/7.2 branch.
# See https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-base-branch-of-a-pull-request.

@singhakanshu00

Copy link
Copy Markdown
Contributor Author

Created manual backport PR here - #86225

cc: @ellatrix

Mamaduka pushed a commit that referenced this pull request Nov 3, 2026
Co-authored-by: singhakanshu00 <akanshusingh@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: andreawetzel <awetz583@git.wordpress.org>
@Mamaduka Mamaduka added Backported to WP Core Pull request that has been successfully merged into WP Core and removed Backport to WP 7.2 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Nov 3, 2026
wporg-sync pushed a commit to WordPress/wordpress-develop that referenced this pull request Nov 3, 2026
This updates the pinned commit hash of the Gutenberg repository from `cc75a79186fd23e72eb015d594e82f40c6209eb5` to `c035c1a649ef68f5c1646694cf440df1d7ae6e62` (fixes cherry-picked to the `wp/7.2` branch).

A full list of changes included in this commit can be found on GitHub: WordPress/gutenberg@cc75a79...c035c1a

- Components: Use solid brand highlights for popup items (WordPress/gutenberg#84583) (#85848)
- Fix endless sideload loop when the browser can't decode a big image (WordPress/gutenberg#83530)
- Notes: Show reaction picker as a row of emoji (WordPress/gutenberg#85819) (#85892)
- Notes: Add thumbs up and plus reactions (WordPress/gutenberg#85565)
- Notes: Share thread focus recovery across actions (WordPress/gutenberg#85455)
- Core Fields: Prevent extra space between `/` and text in slug input (WordPress/gutenberg#85935)
- Notes: Add search and a status filter to the All Notes sidebar (WordPress/gutenberg#84060)
- Notes: Use the note permission check when deleting a reaction (WordPress/gutenberg#85883)
- [WP 7.2] Math block: Keyboard focus is trapped in the LaTeX field when the formula has an error (WordPress/gutenberg#86032)
- Core fields: Keep the status icon full size when its label wraps (WordPress/gutenberg#85828) (#86050)
- [WP 7.2] ToolsPanel: Keep the "Reset" label visible on the highlighted menu item (WordPress/gutenberg#86060)
- Interactivity Router: Ignore router regions and attachTo targets inside data-wp-html content (WordPress/gutenberg#84919) (#86059)
- [WP 7.2] wp-build: Derive CSS module class names from each stylesheet's CSS (WordPress/gutenberg#86062)
- Playlist: Allow track without an attachment ID to render on the frontend (WordPress/gutenberg#83880) (#86158)
- UI: Show only the day number in Calendar day cells (WordPress/gutenberg#86010) (#86183)
- Notes: Tolerate a null comment in the reaction cascade hooks (WordPress/gutenberg#85959)
- Rich Text: Remove stale format boundary when field loses selection (WordPress/gutenberg#86168)
- Notes: Only let a reaction's author delete it (WordPress/gutenberg#85415)
- Writing flow: Fix Arrow Up and Down getting stuck at the edge of the screen (WordPress/gutenberg#85408)
- Try: Run e2e tests in parallel, on one wp-env site per two cores (WordPress/gutenberg#85420)
- Raw handling: Keep shortcodes in text inline (WordPress/gutenberg#85795)
- Fix: Fixes non-breaking space replacement tooltip (WordPress/gutenberg#85777)
- Non-breaking space: Remove non-breaking spaces that would collapse when replaced (WordPress/gutenberg#85873)

Props mamaduka.
See #66340.

git-svn-id: https://develop.svn.wordpress.org/trunk@65225 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Nov 3, 2026
This updates the pinned commit hash of the Gutenberg repository from `cc75a79186fd23e72eb015d594e82f40c6209eb5` to `c035c1a649ef68f5c1646694cf440df1d7ae6e62` (fixes cherry-picked to the `wp/7.2` branch).

A full list of changes included in this commit can be found on GitHub: WordPress/gutenberg@cc75a79...c035c1a

- Components: Use solid brand highlights for popup items (WordPress/gutenberg#84583) (#85848)
- Fix endless sideload loop when the browser can't decode a big image (WordPress/gutenberg#83530)
- Notes: Show reaction picker as a row of emoji (WordPress/gutenberg#85819) (#85892)
- Notes: Add thumbs up and plus reactions (WordPress/gutenberg#85565)
- Notes: Share thread focus recovery across actions (WordPress/gutenberg#85455)
- Core Fields: Prevent extra space between `/` and text in slug input (WordPress/gutenberg#85935)
- Notes: Add search and a status filter to the All Notes sidebar (WordPress/gutenberg#84060)
- Notes: Use the note permission check when deleting a reaction (WordPress/gutenberg#85883)
- [WP 7.2] Math block: Keyboard focus is trapped in the LaTeX field when the formula has an error (WordPress/gutenberg#86032)
- Core fields: Keep the status icon full size when its label wraps (WordPress/gutenberg#85828) (#86050)
- [WP 7.2] ToolsPanel: Keep the "Reset" label visible on the highlighted menu item (WordPress/gutenberg#86060)
- Interactivity Router: Ignore router regions and attachTo targets inside data-wp-html content (WordPress/gutenberg#84919) (#86059)
- [WP 7.2] wp-build: Derive CSS module class names from each stylesheet's CSS (WordPress/gutenberg#86062)
- Playlist: Allow track without an attachment ID to render on the frontend (WordPress/gutenberg#83880) (#86158)
- UI: Show only the day number in Calendar day cells (WordPress/gutenberg#86010) (#86183)
- Notes: Tolerate a null comment in the reaction cascade hooks (WordPress/gutenberg#85959)
- Rich Text: Remove stale format boundary when field loses selection (WordPress/gutenberg#86168)
- Notes: Only let a reaction's author delete it (WordPress/gutenberg#85415)
- Writing flow: Fix Arrow Up and Down getting stuck at the edge of the screen (WordPress/gutenberg#85408)
- Try: Run e2e tests in parallel, on one wp-env site per two cores (WordPress/gutenberg#85420)
- Raw handling: Keep shortcodes in text inline (WordPress/gutenberg#85795)
- Fix: Fixes non-breaking space replacement tooltip (WordPress/gutenberg#85777)
- Non-breaking space: Remove non-breaking spaces that would collapse when replaced (WordPress/gutenberg#85873)

Props mamaduka.
See #66340.
Built from https://develop.svn.wordpress.org/trunk@65225


git-svn-id: http://core.svn.wordpress.org/trunk@64374 1a063a9b-81f0-0310-95a4-ce76da25c4cd
arshidkv12 pushed a commit to arshidkv12/wordpress-develop that referenced this pull request Nov 21, 2026
This updates the pinned commit hash of the Gutenberg repository from `cc75a79186fd23e72eb015d594e82f40c6209eb5` to `c035c1a649ef68f5c1646694cf440df1d7ae6e62` (fixes cherry-picked to the `wp/7.2` branch).

A full list of changes included in this commit can be found on GitHub: WordPress/gutenberg@cc75a79...c035c1a

- Components: Use solid brand highlights for popup items (WordPress/gutenberg#84583) (#85848)
- Fix endless sideload loop when the browser can't decode a big image (WordPress/gutenberg#83530)
- Notes: Show reaction picker as a row of emoji (WordPress/gutenberg#85819) (#85892)
- Notes: Add thumbs up and plus reactions (WordPress/gutenberg#85565)
- Notes: Share thread focus recovery across actions (WordPress/gutenberg#85455)
- Core Fields: Prevent extra space between `/` and text in slug input (WordPress/gutenberg#85935)
- Notes: Add search and a status filter to the All Notes sidebar (WordPress/gutenberg#84060)
- Notes: Use the note permission check when deleting a reaction (WordPress/gutenberg#85883)
- [WP 7.2] Math block: Keyboard focus is trapped in the LaTeX field when the formula has an error (WordPress/gutenberg#86032)
- Core fields: Keep the status icon full size when its label wraps (WordPress/gutenberg#85828) (#86050)
- [WP 7.2] ToolsPanel: Keep the "Reset" label visible on the highlighted menu item (WordPress/gutenberg#86060)
- Interactivity Router: Ignore router regions and attachTo targets inside data-wp-html content (WordPress/gutenberg#84919) (#86059)
- [WP 7.2] wp-build: Derive CSS module class names from each stylesheet's CSS (WordPress/gutenberg#86062)
- Playlist: Allow track without an attachment ID to render on the frontend (WordPress/gutenberg#83880) (#86158)
- UI: Show only the day number in Calendar day cells (WordPress/gutenberg#86010) (#86183)
- Notes: Tolerate a null comment in the reaction cascade hooks (WordPress/gutenberg#85959)
- Rich Text: Remove stale format boundary when field loses selection (WordPress/gutenberg#86168)
- Notes: Only let a reaction's author delete it (WordPress/gutenberg#85415)
- Writing flow: Fix Arrow Up and Down getting stuck at the edge of the screen (WordPress/gutenberg#85408)
- Try: Run e2e tests in parallel, on one wp-env site per two cores (WordPress/gutenberg#85420)
- Raw handling: Keep shortcodes in text inline (WordPress/gutenberg#85795)
- Fix: Fixes non-breaking space replacement tooltip (WordPress/gutenberg#85777)
- Non-breaking space: Remove non-breaking spaces that would collapse when replaced (WordPress/gutenberg#85873)

Props mamaduka.
See #66340.

git-svn-id: https://develop.svn.wordpress.org/trunk@65225 602fd350-edb4-49c9-b593-d223f7449a82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backported to WP Core Pull request that has been successfully merged into WP Core [Package] Format library /packages/format-library [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants