fritx / vue-at

At.js for Vue.
https://fritx.github.io/vue-at/
MIT License
529 stars 114 forks source link

'at' event not emitted when selecting an option #87

Open mochetts opened 5 years ago

mochetts commented 5 years ago

Version: 2.x Browser: Chrome

Description

When typing @ and selecting one of the options without typing anything else, the at event is not fired.

My suspicion is this code here:

if (!keep && chunk.length>0) {
  this.$emit('at', chunk)
}

Given that chunk length is 0 at the moment of the selection (nothing else was typed), the event is not emitted.

Background

I'm trying to use the <at-ta /> (At Textarea) component but I don't have a way to track changes in the text area after selecting one of the members other than hooking to the at event.

Hooking on the at event works, but it doesn't if I select one of the list members right after typing @.

Possible fixes

1) Change the above if condition so that it emits the event even if the chunk.length is 0.

2) Emit a different event (e.g textarea input event) that we can hook on when a member selection is performed.

mochetts commented 5 years ago

Update: Seems that we have an inserted event that gets triggered for the at-textarea component in the latest version. Will use that version instead of 2.x.

fritx commented 5 years ago

@mochetts oh yes, sorry for the missing documentation