-
Notifications
You must be signed in to change notification settings - Fork 132
fix: always call resolveComment after custom TC bubble handlers (SD-2049) #2204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
caio-pizzol
merged 2 commits into
main
from
caio/sd-2049-tc-bubble-persists-when-using-custom-acceptreject-handlers
Feb 27, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
tests/behavior/tests/comments/sd-2049-custom-tc-handler-ghost-bubble.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| import { test, expect } from '../../fixtures/superdoc.js'; | ||
| import { assertDocumentApiReady, listTrackChanges } from '../../helpers/document-api.js'; | ||
| import { activateCommentDialog } from '../../helpers/comments.js'; | ||
|
|
||
| test.use({ config: { toolbar: 'full', comments: 'on', trackChanges: true } }); | ||
|
|
||
| test('SD-2049 last TC bubble disappears when using custom accept handler', async ({ superdoc }) => { | ||
| await assertDocumentApiReady(superdoc.page); | ||
|
|
||
| // Type two words on separate lines so we get two independent tracked changes | ||
| await superdoc.type('first'); | ||
| await superdoc.newLine(); | ||
| await superdoc.type('second'); | ||
| await superdoc.waitForStable(); | ||
|
|
||
| // Switch to suggesting mode | ||
| await superdoc.setDocumentMode('suggesting'); | ||
| await superdoc.waitForStable(); | ||
|
|
||
| // Create tracked change on "first" — select and replace | ||
| const pos1 = await superdoc.findTextPos('first'); | ||
| await superdoc.setTextSelection(pos1, pos1 + 'first'.length); | ||
| await superdoc.waitForStable(); | ||
| await superdoc.type('alpha'); | ||
| await superdoc.waitForStable(); | ||
|
|
||
| // Create tracked change on "second" — select and replace | ||
| const pos2 = await superdoc.findTextPos('second'); | ||
| await superdoc.setTextSelection(pos2, pos2 + 'second'.length); | ||
| await superdoc.waitForStable(); | ||
| await superdoc.type('beta'); | ||
| await superdoc.waitForStable(); | ||
|
|
||
| // Wait for both tracked changes to be registered | ||
| await expect.poll(async () => (await listTrackChanges(superdoc.page)).total).toBeGreaterThanOrEqual(2); | ||
|
|
||
| // Inject custom accept handler — this is the SD-2049 scenario | ||
| await superdoc.page.evaluate(() => { | ||
| const sd = (window as any).superdoc; | ||
| sd.config.onTrackedChangeBubbleAccept = (comment: any, editor: any) => { | ||
| editor.commands.acceptTrackedChangeById(comment.commentId); | ||
| }; | ||
| }); | ||
|
|
||
| // Accept tracked changes one by one via bubble UI | ||
| const dialog1 = await activateCommentDialog(superdoc, 'alpha'); | ||
| await expect(dialog1).toBeVisible({ timeout: 5_000 }); | ||
|
|
||
| // Click the accept button — use force because the overflow-menu icon | ||
| // sits inside the comment-header and Playwright sees the header as intercepting | ||
| await dialog1.locator('.overflow-menu .overflow-menu__icon').first().click({ force: true }); | ||
| await superdoc.waitForStable(); | ||
| await superdoc.page.waitForTimeout(500); | ||
|
|
||
| // Now handle the second (last) tracked change — this is where SD-2049 would fail | ||
| const remainingTCs = await listTrackChanges(superdoc.page); | ||
|
|
||
| if (remainingTCs.total > 0) { | ||
| const dialog2 = await activateCommentDialog(superdoc, 'beta'); | ||
| await expect(dialog2).toBeVisible({ timeout: 5_000 }); | ||
|
|
||
| // Accept the last bubble | ||
| await dialog2.locator('.overflow-menu .overflow-menu__icon').first().click({ force: true }); | ||
| await superdoc.waitForStable(); | ||
| } | ||
|
|
||
| // The key assertion: no unresolved floating comment dialogs should remain. | ||
| // Before the SD-2049 fix, the last bubble would persist as a ghost. | ||
| await expect(superdoc.page.locator('.comment-placeholder .comments-dialog:not(.is-resolved)')).toHaveCount(0, { | ||
| timeout: 5_000, | ||
| }); | ||
|
|
||
| await superdoc.snapshot('sd-2049-no-ghost-bubbles'); | ||
| }); | ||
|
|
||
| test('SD-2049 last TC bubble disappears when using custom reject handler', async ({ superdoc }) => { | ||
| await assertDocumentApiReady(superdoc.page); | ||
|
|
||
| await superdoc.type('hello world'); | ||
| await superdoc.waitForStable(); | ||
|
|
||
| await superdoc.setDocumentMode('suggesting'); | ||
| await superdoc.waitForStable(); | ||
|
|
||
| // Create a single tracked change | ||
| const pos = await superdoc.findTextPos('hello'); | ||
| await superdoc.setTextSelection(pos, pos + 'hello'.length); | ||
| await superdoc.waitForStable(); | ||
| await superdoc.type('goodbye'); | ||
| await superdoc.waitForStable(); | ||
|
|
||
| await expect.poll(async () => (await listTrackChanges(superdoc.page)).total).toBeGreaterThanOrEqual(1); | ||
|
|
||
| // Inject custom reject handler | ||
| await superdoc.page.evaluate(() => { | ||
| const sd = (window as any).superdoc; | ||
| sd.config.onTrackedChangeBubbleReject = (comment: any, editor: any) => { | ||
| editor.commands.rejectTrackedChangeById(comment.commentId); | ||
| }; | ||
| }); | ||
|
|
||
| // Activate the TC bubble and click reject (second icon in overflow menu) | ||
| const dialog = await activateCommentDialog(superdoc, 'goodbye'); | ||
| await expect(dialog).toBeVisible({ timeout: 5_000 }); | ||
| await dialog.locator('.overflow-menu .overflow-menu__icon').nth(1).click({ force: true }); | ||
| await superdoc.waitForStable(); | ||
|
|
||
| // No ghost bubbles should remain | ||
| await expect(superdoc.page.locator('.comment-placeholder .comments-dialog:not(.is-resolved)')).toHaveCount(0, { | ||
| timeout: 5_000, | ||
| }); | ||
|
|
||
| // Text should be reverted since we rejected | ||
| await superdoc.assertTextContains('hello'); | ||
|
|
||
| await superdoc.snapshot('sd-2049-reject-no-ghost-bubble'); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handleResolvenow callsprops.comment.resolveComment(...)even whenonTrackedChangeBubbleAccepthandled the action, so a custom handler that is async, no-op, or aborts on validation failure will still mark the tracked-change comment as resolved and remove its bubble. In those cases the accept/reject command may never run, leaving an unresolved tracked change with no bubble UI to act on, which breaks existing integrations that rely on custom handlers to decide whether to proceed.Useful? React with 👍 / 👎.