Skip to content

Commit

Permalink
fix: Duplicate comment menus
Browse files Browse the repository at this point in the history
  • Loading branch information
areknawo committed May 27, 2024
1 parent 34b8ad4 commit 991c2b3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ const CommentMenu: Component<BlockActionMenuProps> = (props) => {
};

if (existingFragmentIndex >= 0) {
newFragments.push(Object.assign(fragments()[existingFragmentIndex], newFragment));
newFragments.splice(
existingFragmentIndex,
1,
Object.assign(fragments()[existingFragmentIndex], newFragment)
);
} else {
newFragments.push(newFragment);
}
Expand Down
6 changes: 5 additions & 1 deletion apps/web/src/lib/editor/extensions/element/node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,11 @@ const Element = BaseElement.extend<
) {
const isAtEnd = newState.selection.$from.pos === newState.doc.nodeSize - 3;

if (isAtEnd && !oldState.selection.eq(newState.selection)) {
if (
isAtEnd &&
!(oldState.selection instanceof TextSelection) &&
!oldState.selection.eq(newState.selection)
) {
return newState.tr.setSelection(
Selection.near(
newState.tr.doc.resolve(
Expand Down

0 comments on commit 991c2b3

Please sign in to comment.