mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 05:07:53 +08:00
FIX: ensures correct scroll position of textarea after autocomplete (#6942)
This commit is contained in:
parent
671ff4243f
commit
e5765fe1f5
|
@ -163,7 +163,11 @@ export default Ember.Component.extend({
|
|||
includeMentionableGroups: true
|
||||
}),
|
||||
key: "@",
|
||||
transformComplete: v => v.username || v.name
|
||||
transformComplete: v => v.username || v.name,
|
||||
afterComplete() {
|
||||
// ensures textarea scroll position is correct
|
||||
Ember.run.scheduleOnce("afterRender", () => $input.blur().focus());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -385,10 +385,14 @@ export default Ember.Component.extend({
|
|||
|
||||
_applyCategoryHashtagAutocomplete() {
|
||||
const siteSettings = this.siteSettings;
|
||||
const self = this;
|
||||
|
||||
this.$(".d-editor-input").autocomplete({
|
||||
template: findRawTemplate("category-tag-autocomplete"),
|
||||
key: "#",
|
||||
afterComplete() {
|
||||
self._focusTextArea();
|
||||
},
|
||||
transformComplete(obj) {
|
||||
return obj.text;
|
||||
},
|
||||
|
@ -416,6 +420,7 @@ export default Ember.Component.extend({
|
|||
key: ":",
|
||||
afterComplete(text) {
|
||||
self.set("value", text);
|
||||
self._focusTextArea();
|
||||
},
|
||||
|
||||
onKeyUp(text, cp) {
|
||||
|
@ -722,7 +727,7 @@ export default Ember.Component.extend({
|
|||
$textarea.prop("selectionStart", (pre + text).length + 2);
|
||||
$textarea.prop("selectionEnd", (pre + text).length + 2);
|
||||
|
||||
Ember.run.scheduleOnce("afterRender", () => $textarea.focus());
|
||||
this._focusTextArea();
|
||||
},
|
||||
|
||||
_addText(sel, text, options) {
|
||||
|
@ -747,7 +752,8 @@ export default Ember.Component.extend({
|
|||
$textarea.val(value);
|
||||
$textarea.prop("selectionStart", insert.length);
|
||||
$textarea.prop("selectionEnd", insert.length);
|
||||
Ember.run.scheduleOnce("afterRender", () => $textarea.focus());
|
||||
|
||||
this._focusTextArea();
|
||||
},
|
||||
|
||||
_extractTable(text) {
|
||||
|
@ -838,6 +844,12 @@ export default Ember.Component.extend({
|
|||
}
|
||||
},
|
||||
|
||||
// ensures textarea scroll position is correct
|
||||
_focusTextArea() {
|
||||
const $textarea = this.$("textarea.d-editor-input");
|
||||
Ember.run.scheduleOnce("afterRender", () => $textarea.blur().focus());
|
||||
},
|
||||
|
||||
actions: {
|
||||
emoji() {
|
||||
if (this.get("disabled")) {
|
||||
|
@ -850,6 +862,7 @@ export default Ember.Component.extend({
|
|||
emojiSelected(code) {
|
||||
let selected = this._getSelected();
|
||||
const captures = selected.pre.match(/\B:(\w*)$/);
|
||||
|
||||
if (_.isEmpty(captures)) {
|
||||
this._addText(selected, `:${code}:`);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user