Skip to content

Commit c4bbc37

Browse files
committed
fix: hide popover on null coords and fix inserMention typo
Hide tippy when coordsAtPos returns null to prevent stale popover position. Rename inserMention to insertMention across popover-plugin and Mentions.vue.
1 parent 6acfc2f commit c4bbc37

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

packages/super-editor/src/components/popovers/Mentions.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const props = defineProps({
1010
type: String,
1111
default: '',
1212
},
13-
inserMention: {
13+
insertMention: {
1414
type: Function,
1515
required: true,
1616
},
@@ -33,7 +33,7 @@ const getFilteredUsers = computed(() => {
3333
});
3434
3535
const handleClick = (user) => {
36-
props.inserMention(user);
36+
props.insertMention(user);
3737
};
3838
3939
const handleKeydown = (event) => {
@@ -50,7 +50,7 @@ const handleKeydown = (event) => {
5050
} else if (event.key === 'Enter') {
5151
const user = getFilteredUsers.value[activeUserIndex.value];
5252
if (user) {
53-
props.inserMention(user);
53+
props.insertMention(user);
5454
}
5555
}
5656
};

packages/super-editor/src/extensions/popover-plugin/popover-plugin.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class Popover {
126126
props: {
127127
users: this.editor.users,
128128
mention: atMention,
129-
inserMention: (user) => {
129+
insertMention: (user) => {
130130
// Use fresh state from the view, not the stale captured state
131131
const currentState = this.editor.view.state;
132132
const { $from } = currentState.selection;
@@ -151,7 +151,10 @@ class Popover {
151151

152152
showPopoverAtPosition(pos) {
153153
const coords = this.editor.coordsAtPos(pos);
154-
if (!coords) return;
154+
if (!coords) {
155+
this.tippyInstance.hide();
156+
return;
157+
}
155158

156159
this.popoverRect = {
157160
width: 0,

0 commit comments

Comments
 (0)