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:
parent
8d1da9cedd
commit
cd84a05600
|
@ -301,7 +301,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 "";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue