mirror of
https://github.com/discourse/discourse.git
synced 2025-02-09 12:54:56 +00: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
|
includeMentionableGroups: true
|
||||||
}),
|
}),
|
||||||
key: "@",
|
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() {
|
_applyCategoryHashtagAutocomplete() {
|
||||||
const siteSettings = this.siteSettings;
|
const siteSettings = this.siteSettings;
|
||||||
|
const self = this;
|
||||||
|
|
||||||
this.$(".d-editor-input").autocomplete({
|
this.$(".d-editor-input").autocomplete({
|
||||||
template: findRawTemplate("category-tag-autocomplete"),
|
template: findRawTemplate("category-tag-autocomplete"),
|
||||||
key: "#",
|
key: "#",
|
||||||
|
afterComplete() {
|
||||||
|
self._focusTextArea();
|
||||||
|
},
|
||||||
transformComplete(obj) {
|
transformComplete(obj) {
|
||||||
return obj.text;
|
return obj.text;
|
||||||
},
|
},
|
||||||
@ -416,6 +420,7 @@ export default Ember.Component.extend({
|
|||||||
key: ":",
|
key: ":",
|
||||||
afterComplete(text) {
|
afterComplete(text) {
|
||||||
self.set("value", text);
|
self.set("value", text);
|
||||||
|
self._focusTextArea();
|
||||||
},
|
},
|
||||||
|
|
||||||
onKeyUp(text, cp) {
|
onKeyUp(text, cp) {
|
||||||
@ -722,7 +727,7 @@ export default Ember.Component.extend({
|
|||||||
$textarea.prop("selectionStart", (pre + text).length + 2);
|
$textarea.prop("selectionStart", (pre + text).length + 2);
|
||||||
$textarea.prop("selectionEnd", (pre + text).length + 2);
|
$textarea.prop("selectionEnd", (pre + text).length + 2);
|
||||||
|
|
||||||
Ember.run.scheduleOnce("afterRender", () => $textarea.focus());
|
this._focusTextArea();
|
||||||
},
|
},
|
||||||
|
|
||||||
_addText(sel, text, options) {
|
_addText(sel, text, options) {
|
||||||
@ -747,7 +752,8 @@ export default Ember.Component.extend({
|
|||||||
$textarea.val(value);
|
$textarea.val(value);
|
||||||
$textarea.prop("selectionStart", insert.length);
|
$textarea.prop("selectionStart", insert.length);
|
||||||
$textarea.prop("selectionEnd", insert.length);
|
$textarea.prop("selectionEnd", insert.length);
|
||||||
Ember.run.scheduleOnce("afterRender", () => $textarea.focus());
|
|
||||||
|
this._focusTextArea();
|
||||||
},
|
},
|
||||||
|
|
||||||
_extractTable(text) {
|
_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: {
|
actions: {
|
||||||
emoji() {
|
emoji() {
|
||||||
if (this.get("disabled")) {
|
if (this.get("disabled")) {
|
||||||
@ -850,6 +862,7 @@ export default Ember.Component.extend({
|
|||||||
emojiSelected(code) {
|
emojiSelected(code) {
|
||||||
let selected = this._getSelected();
|
let selected = this._getSelected();
|
||||||
const captures = selected.pre.match(/\B:(\w*)$/);
|
const captures = selected.pre.match(/\B:(\w*)$/);
|
||||||
|
|
||||||
if (_.isEmpty(captures)) {
|
if (_.isEmpty(captures)) {
|
||||||
this._addText(selected, `:${code}:`);
|
this._addText(selected, `:${code}:`);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user