Skip to content

fix: remove persisting yellow underline after canceling track-format suggestion#2212

Closed
gpardhivvarma wants to merge 6 commits intosuperdoc-dev:mainfrom
gpardhivvarma:fix/track-format-yellow-underline-persists-v2
Closed

fix: remove persisting yellow underline after canceling track-format suggestion#2212
gpardhivvarma wants to merge 6 commits intosuperdoc-dev:mainfrom
gpardhivvarma:fix/track-format-yellow-underline-persists-v2

Conversation

@gpardhivvarma
Copy link
Copy Markdown
Contributor

Summary

  • Fix 1 (addMarkStep.js): Clamp TrackFormat addMark range to per-node boundaries (Math.max(step.from, pos) / Math.min(step.to, pos + node.nodeSize)) instead of using the full step range, preventing incorrect before/after arrays from leaking onto adjacent text nodes.
  • Fix 2 (removeMarkStep.js): When a tracked format addition is fully reversed (after becomes empty after filtering), remove the TrackFormat mark entirely instead of creating a new one with after=[] and a stale before array — which would keep the gold/yellow underline visible for a no-op change.

Test plan

  • All 7203 unit tests pass (pnpm --filter super-editor test)
  • Behavior tests: pnpm --filter behavior test -- reject-format-suggestion (requires Playwright browsers installed)
  • Manual: enable track changes → select text → bold → bold again (toggle off) → verify yellow underline disappears
  • Manual: enable track changes → select text → bold → reject via suggestion bubble → verify both bold and underline disappear

…suggestion

Two bugs caused the gold/yellow TrackFormat underline to persist after
reversing a tracked format change:

1. addMarkStep applied TrackFormat using the full step range instead of
   clamped per-node boundaries, leaking wrong before/after arrays onto
   adjacent text nodes.

2. removeMarkStep didn't clean up fully-reversed format changes — when
   a tracked addition was toggled back (after=[] but before had items),
   the TrackFormat mark persisted instead of being removed.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: acc9ad563a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Narrowed the early-exit condition so TrackFormat is only removed when
both arrays are empty (true no-op). Keeps the mark when before has
legitimate tracked removals (e.g. before=[italic], after=[]).
@gpardhivvarma
Copy link
Copy Markdown
Contributor Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 201e7c9a7a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Hoist a sharedWid variable so all inline nodes touched by a single
addMarkStep reuse the same TrackFormat ID. With per-node clamped ranges,
getLiveInlineMarksInRange no longer sees the previous node's TrackFormat,
causing each node to generate a separate UUID. This broke ID-based
reject/accept flows for multi-node selections.
Mirror the sharedWid pattern from addMarkStep. When an existing
formatChangeMark is present, reuse its ID to preserve change grouping.
When creating new TrackFormat marks across multiple nodes, share a
single generated ID so reject/accept treats them as one change.
@gpardhivvarma
Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@gpardhivvarma
Copy link
Copy Markdown
Contributor Author

@caio-pizzol please review at the earliest

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.

@gpardhivvarma solid fix — addresses the root cause (wrong ranges, mismatched IDs, missing cleanup) not just symptoms. left one comment about tests.

Cover the three fixes from this PR:
- Shared TrackFormat ID across nodes in a single AddMarkStep
- TrackFormat removal when toggling a tracked addition back (empty after + empty before)
- TrackFormat retention when before is non-empty (real tracked removal)
@gpardhivvarma
Copy link
Copy Markdown
Contributor Author

@caio-pizzol Please take a look at it

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.

@gpardhivvarma the before-only diff fix and the shared wid pattern are both in good shape — nice. left two small things on the new test file: an unused import and a gap in test coverage that would let the range-clamping fix go unguarded if it's ever changed. the coverage one is worth a look before merging, the import is a quick fix.

@gpardhivvarma
Copy link
Copy Markdown
Contributor Author

@caio-pizzol

@caio-pizzol
Copy link
Copy Markdown
Contributor

Thanks for the work on this @gpardhivvarma! The range clamping and sharedWid fixes are correct.

We found one remaining edge case when canceling a format change on nodes with pre-existing marks (e.g., bold on/off on italic text leaves a ghost "removed italic" mark). We've built on your commits and added the fix in #2233.

Closing in favor of #2233. Appreciate the contribution!

@caio-pizzol caio-pizzol closed this Mar 2, 2026
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.

2 participants