Skip to content

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

Merged
chittolinag merged 6 commits into
mainfrom
gabriel/sd-2678-bug-cannot-delete-contentlocked-inline-sdt-with-normal
May 8, 2026
Merged

SD-2678 - Cannot delete contentlocked inline sdt with normal#3129
chittolinag merged 6 commits into
mainfrom
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)) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hey @caio-pizzol ! I could not reproduce this one, at least not manually. seems to work fine here. maybe let's get on a call to figure it out whether we're doing something different?

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.

hey @chittolinag! I was able to reproduce this issue using the document attached

sdt-cut-regression-repro.docx

If you click the UNLOCKED_FIELD_VALUE sdt and then press Cmd+X, it doesn't do anything. Loading the same document in the main branch actually does cut the text.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ah I think I get it. if you single click the field, cmd + x won't work. if you double click it, it works. at least that's the behavior from my side.

@chittolinag chittolinag enabled auto-merge (squash) May 8, 2026 17:47
@chittolinag chittolinag requested review from caio-pizzol and removed request for artem-harbour and caio-pizzol May 8, 2026 17:48
Copy link
Copy Markdown
Contributor

@luccas-harbour luccas-harbour left a comment

Choose a reason for hiding this comment

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

LGTM

@chittolinag chittolinag merged commit b57acbe into main May 8, 2026
65 checks passed
@chittolinag chittolinag deleted the gabriel/sd-2678-bug-cannot-delete-contentlocked-inline-sdt-with-normal branch May 8, 2026 19:37
@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 11, 2026

🎉 This PR is included in superdoc v1.30.0-next.71

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 11, 2026

🎉 This PR is included in @superdoc-dev/react v1.2.0-next.116

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 11, 2026

🎉 This PR is included in @superdoc-dev/mcp v0.3.0-next.74

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 11, 2026

🎉 This PR is included in vscode-ext v2.3.0-next.118

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 11, 2026

🎉 This PR is included in superdoc-cli v0.8.0-next.90

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 11, 2026

🎉 This PR is included in superdoc-sdk v1.8.0-next.72

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.

7 participants