Skip to content

Commit 7c3bafe

Browse files
handsomezywkagol
authored andcommitted
fix(mention): 修复Mention 组件的联想文字选中后应替换触发输入的联想文本,而非追加 #1303
1 parent c25fb4a commit 7c3bafe

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/devui-vue/devui/mention/src/mention.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default defineComponent({
6767
e.stopPropagation();
6868
e.preventDefault();
6969
showSuggestions.value = false;
70-
textContext.value += item[props.dmValueParse.value as keyof IMentionSuggestionItem];
70+
textContext.value = textContext.value.substring(0, 1) + item[props.dmValueParse.value as keyof IMentionSuggestionItem];
7171
};
7272

7373
const arrowKeyDown = (e: KeyboardEvent) => {
@@ -102,7 +102,9 @@ export default defineComponent({
102102
e.stopPropagation();
103103
e.preventDefault();
104104
showSuggestions.value = false;
105-
textContext.value += filteredSuggestions.value[currentIndex.value][props.dmValueParse.value as keyof IMentionSuggestionItem];
105+
textContext.value =
106+
textContext.value.substring(0, 1) +
107+
filteredSuggestions.value[currentIndex.value][props.dmValueParse.value as keyof IMentionSuggestionItem];
106108
emit('select', filteredSuggestions.value[currentIndex.value]);
107109
}
108110
}

0 commit comments

Comments
 (0)