FIX: Remove existing characters when a new emoji is selected.

When the user choose an emoji from the "More..." option, any previously typed character should be discarded.
This commit is contained in:
Duong Tam Chau 2016-02-22 20:07:19 -05:00
parent 8d1da9cedd
commit cd84a05600
1 changed files with 10 additions and 1 deletions

View File

@ -301,7 +301,16 @@ export default Ember.Component.extend({
showSelector({ showSelector({
appendTo: self.$(), appendTo: self.$(),
container, 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 ""; return "";
} }