Skip to content

SD-2678 - Cannot delete contentlocked inline sdt with normal#3129

Open
chittolinag wants to merge 4 commits intomainfrom
gabriel/sd-2678-bug-cannot-delete-contentlocked-inline-sdt-with-normal
Open

SD-2678 - Cannot delete contentlocked inline sdt with normal#3129
chittolinag wants to merge 4 commits intomainfrom
gabriel/sd-2678-bug-cannot-delete-contentlocked-inline-sdt-with-normal

Conversation

@chittolinag
Copy link
Copy Markdown
Contributor

Issue

Structured content blocks (SDTs) configured with contentLocked could not be deleted as a whole. Users could neither remove them with backspace/delete at the wrapper boundary, nor select-and-delete the field — the lock plugin treated wrapper-level actions as in-content edits and blocked them.

Proposed solution

Refined the structured-content lock plugin so it distinguishes wrapper-level actions from content edits:

  • A selection that exactly covers an SDT's content is promoted to a wrapper NodeSelection, so the next destructive keypress removes the whole field (matching Word's "click to select, key to delete" behavior).
  • Backspace/delete at an SDT boundary is recognized as a wrapper-touching action and the affected range is expanded to the wrapper, so contentLocked no longer blocks deletion of the field itself.

Lock modes that protect the wrapper (sdtLocked, sdtContentLocked) still prevent removal. Added unit tests covering the new paths.

@linear
Copy link
Copy Markdown

linear Bot commented May 4, 2026

…annot-delete-contentlocked-inline-sdt-with-normal

# Conflicts:
#	pnpm-lock.yaml
@chittolinag chittolinag marked this pull request as ready for review May 4, 2026 20:42
@chittolinag chittolinag requested a review from a team as a code owner May 4, 2026 20:42
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

@caio-pizzol caio-pizzol left a comment

Choose a reason for hiding this comment

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

hey @chittolinag! the original bug is fixed in the dev app :)

one thing to flag: Cmd+X breaks for unlocked fields. select the text inside, press Cmd+X, nothing gets cut and the whole field gets selected instead. fix is one line.

approve once that's in.

// NodeSelection on the wrapper so the user sees the whole field
// highlighted and the next destructive press deletes it (matches
// Word's "click to select, key to delete").
if (from !== to && !(selection instanceof NodeSelection)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

repro: open any unlocked inline field, triple-click to highlight the text inside, press Cmd+X. clipboard stays unchanged, the field's text is still there, and the highlight jumps to the whole field. paste anywhere to confirm "controlled text" is not on the clipboard. only Backspace and Delete should go through this branch:

Suggested change
if (from !== to && !(selection instanceof NodeSelection)) {
if ((isBackspace || isDelete) && from !== to && !(selection instanceof NodeSelection)) {

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants