Merge pull request #4028 from dtchau/fix/more_emoji_autocomplete_issue

FIX: Remove existing characters when a new emoji is selected.
This commit is contained in:
Sam 2016-02-27 17:00:05 +11:00
commit 1f688e966d
1 changed files with 10 additions and 1 deletions

View File

@ -309,7 +309,16 @@ export default Ember.Component.extend({
showSelector({
appendTo: self.$(),
container,
onSelect: title => self._addText(self._getSelected(), `${title}:`)
onSelect: title => {
// Remove the previously type characters when a new emoji is selected from the selector.
let selected = self._getSelected();
let newPre = selected.pre.replace(/:[^:]+$/, ":");
let numOfRemovedChars = selected.pre.length - newPre.length;
selected.pre = newPre;
selected.start -= numOfRemovedChars;
selected.end -= numOfRemovedChars;
self._addText(selected, `${title}:`);
}
});
return "";
}