Skip to content

Commit 0adbd01

Browse files
committed
fix: undo accidental revert
1 parent de46bd8 commit 0adbd01

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
describe('with allow-space prop', () => {
22
it('shows suggestions after typing mention containing space', () => {
33
cy.visit('/allow-space')
4-
cy.get('.input').type('abc @space ')
4+
cy.get('.input').type('abc @space in')
55
cy.get('.v-popper__popper').should('be.visible')
66
.should('contain', 'space invader')
7+
cy.get('.input').type('{enter}')
8+
cy.get('.preview').should('contain', '@space invader')
79
})
810
})

packages/vue-mention/src/Mentionable.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,9 @@ export default defineComponent({
267267
if (!(keyIndex < 1 || /\s/.test(getValue()[keyIndex - 1]))) {
268268
return false
269269
}
270-
const indexAtKey = props.allowSpace ? getValue()[index - 1] === key : true
271-
if (text != null && indexAtKey) {
270+
const keyIsBeforeCaret = getValue()[index - 1] === key
271+
const shouldOpen = props.allowSpace ? isMentioning.value || keyIsBeforeCaret : true
272+
if (text != null && shouldOpen) {
272273
openMenu(key, keyIndex)
273274
searchText.value = text
274275
return true

0 commit comments

Comments
 (0)