Skip to content

Commit 835f839

Browse files
committed
fix: defer commentsUpdate emission to after transaction completes
1 parent ad7b36b commit 835f839

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

packages/super-editor/src/extensions/comment/comments-plugin.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,12 +338,13 @@ export const CommentsPlugin = Extension.create({
338338
const newActiveThreadId = meta.activeThreadId;
339339

340340
// Emit commentsUpdate event when active comment changes (e.g., from comment bubble click)
341+
// Defer emission to after transaction completes to avoid dispatching during apply()
341342
if (previousActiveThreadId !== newActiveThreadId) {
342343
const update = {
343344
type: comments_module_events.SELECTED,
344345
activeCommentId: newActiveThreadId ? newActiveThreadId : null,
345346
};
346-
editor.emit('commentsUpdate', update);
347+
setTimeout(() => editor.emit('commentsUpdate', update), 0);
347348
}
348349

349350
pluginState.activeThreadId = newActiveThreadId;

0 commit comments

Comments
 (0)