Skip to content

Block Editor: Check supported bindings when copying selected text - #84389

Open
salvatorecorsi wants to merge 10 commits into
WordPress:trunkfrom
salvatorecorsi:fix/copy-bound-block-text
Open

salvatorecorsi wants to merge 10 commits into
WordPress:trunkfrom
salvatorecorsi:fix/copy-bound-block-text

Conversation

@salvatorecorsi

@salvatorecorsi salvatorecorsi commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

What?

Restrict the bound-text clipboard exception to bindings supported by the selected attribute, and resolve pattern override defaults with the existing binding utility.

The general fully selected bound-text copy path from #84362 is now in trunk. This PR retains the supported-attribute and pattern-default guard, plus regression coverage for that path.

Why?

A binding on another attribute, an unsupported selected attribute, or a non-pattern default should not bypass whole-block serialization. Otherwise copying can discard the block wrapper and binding metadata even though the selected text is not a supported bound field.

How?

Read the block's supported binding attributes, normalize pattern override defaults, and use the RichText copy path only when the selected attribute has a supported binding. Preserve trunk's clipboard and iframe changes.

Testing Instructions

  1. Open an editor with a paragraph whose content is bound to a registered, REST-visible post-meta field. Set a non-empty meta value while leaving the stored paragraph content empty. The Playground example in Copying the block when its entire text is selected can prevent the text from being copied #84362 provides a reproduction fixture.
  2. Select all of the visible words by dragging across the text, then copy and paste into a plain-text application. The complete resolved text should appear.
  3. Repeat with bound text containing inline formatting and paste into a rich-text field. The formatting should be preserved.
  4. Select all text in an unbound heading and copy/paste within the editor. It should still produce a heading block.
  5. Copy a bound block with a collapsed text selection, then copy multiple selected blocks. Pasting within the editor should preserve their bindings.

Validation after the trunk merge (2026-10-16)

Merged trunk at 6b45881480c272953c52090a686b0b8ca679c051 with a normal merge, retaining the upstream and PR changelog entries. The fully selected bound-text copy correction remains unchanged, and upstream's paste-handling improvements are preserved.

  • npm run build passed (298 seconds).
  • npm run test:unit -- packages/block-editor --project=node --project=jsdom passed: 145 files, 2,324 tests, including the bound-text clipboard regressions.
  • npm run typecheck passed.
  • npm run test:unit:conventions passed.
  • npm exec --no -- lint-staged --concurrent false --diff=6b45881480c272953c52090a686b0b8ca679c051 passed, including formatting, prelint, ESLint, and generated-documentation consistency checks; the checked tree was preserved.
  • Scoped JavaScript ESLint passed for the complete PR diff.
  • npm run lint:changelogs -- --require-pr=84389 packages/block-editor/CHANGELOG.md passed.

The two copy E2E cases were not rerun locally during this merge update because the Docker wp-env environment is unavailable. CI for the updated merge revision is pending.

Testing Instructions for Keyboard

For a single-line bound paragraph, place the caret in its text. On Windows/Linux, use Home followed by Shift+End; on macOS, use Cmd+Left followed by Cmd+Shift+Right. Copy with Ctrl+C or Cmd+C, paste into a plain-text field, and verify the complete phrase. With a collapsed text selection, copy/paste the block within the editor and verify its binding is preserved.

The keyboard-only sequence has not been manually verified locally.

Could a maintainer add the [Type] Bug label? I do not have permission to apply upstream labels.

Validation update — 9 November 2026

Merged trunk c8e6627f9d4575b27cb95887c538b4c95817c20e and validated published head 99ff73534ccf0bf4e3ba8549fba04b086bb165cf. This includes the required trunk baseline.

  • Full JavaScript build and TypeScript checks passed.
  • Related automated tests passed: 3281 cases across 214 files (unit).
  • scoped JavaScript lint, package changelog checks, repository conventions, tsconfig validation, and diff whitespace checks passed.

These are local validation results; hosted CI and maintainer-only label requirements remain separate.

The final follow-up changes only the changelog to describe the supported-binding/pattern-default guard that remains beyond trunk. Production and test files are byte-identical to 1d87ee6343e7d38e93bfa7e58c86f439ec2c2991, so its full build, typecheck and 3,281 passing cases are retained; the actual final changelog passed the repository changelog validator and diff checks.

Validation update — 20 November 2026

Resolved the actual conflicts by merging trunk 3c872fce8cff38d2a8d38cd48a62575895114fb8 normally. Published head: e5ef2d0af2a8891f890117a07e68991a3c1f8963.

The PR's own source and regression-test blobs are unchanged; upstream release notes are preserved and this PR's changelog entries remain under Unreleased.

  • The full production build and full repository typecheck passed.
  • Scoped functional tests passed: 11 cases in 1 file(s) (unit). Counts are executions within these scopes, not distinct tests across PRs.
  • Scoped lint, package changelog checks, tsconfig validation, test conventions and documentation generation/cleanliness checks passed.

These are local branch-update results. Hosted CI is tracked separately; no full Docker E2E or published-dependency audit is claimed for this update.

Use of AI Tools

OpenAI Codex generated the implementation, regression tests, and this description. Codex also performed the current merge-maintenance source review and automated validation listed above. The contributor remains responsible for reviewing the generated work, and the change requires maintainer review.

@github-actions github-actions Bot added the [Package] Block editor /packages/block-editor label Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

👋 Welcome

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @salvatorecorsi! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

🎉 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: salvatorecorsi <salvatorecorsi@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.

🏷️ Labels

This pull request needs exactly one label indicating its type, and has 0.

  • Required: any label starting with [Type].
  • Found: none.

Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you.

@github-actions github-actions Bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Oct 9, 2026
salvatorecorsi and others added 3 commits October 16, 2026 07:38
Retain supported binding and pattern override handling in the upstream clipboard path. Migrate the regression tests to TypeScript and the current RichText event delegation API. Validated production build, full typecheck, 296 focused tests, Vitest conventions, and scoped lint-staged checks.
@salvatorecorsi salvatorecorsi changed the title Block Editor: Fix copying fully selected bound text Block Editor: Check supported bindings when copying selected text Nov 9, 2026

salvatorecorsi commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Merged trunk at e5ef2d0a to resolve the current conflicts and revalidated the branch. The earlier rerun request below applies to the previous head; please use the checks on the new head for review.

Superseded CI follow-up

Could a maintainer rerun Chromium shard 2? On the current head (11e0238a), it spent six hours installing browser system dependencies and was cancelled before any tests ran. The unit-test status check only reports that cancellation. My upstream access is read-only.

Earlier CI follow-up on superseded heads

A changelog-only follow-up at 99ff7353 now describes the supported-binding guard that remains beyond trunk. Production and test files are unchanged. Full CI for this head is queued/running, so no additional rerun is needed while that run is in progress; this is not a claim that the earlier Chromium interruption passed.

Earlier CI follow-up on the previous head

Could a maintainer rerun the Chromium job? It stops with VITEST_BROWSER_CONNECTION_CLOSED while running the existing Tabs overflow fixture, after 1,815 passing cases. No failing assertion is recorded, and Tabs and the browser setup are identical to the CI base. The fixture passes locally with seed 195545; that focused Windows run does not cover the preceding Linux test order or establish a full-suite pass. My upstream access is read-only.

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

First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Package] Block editor /packages/block-editor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant