From 08e43588f6316e29bb6fe51c308712196f591fee Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 1 Mar 2016 15:16:58 -0500 Subject: [PATCH] FIX: Autocomplete wasn't properly updating `d-editor` --- app/assets/javascripts/discourse/components/d-editor.js.es6 | 3 +++ app/assets/javascripts/discourse/lib/autocomplete.js.es6 | 4 ++++ app/assets/javascripts/discourse/templates/discovery.hbs | 2 ++ 3 files changed, 9 insertions(+) diff --git a/app/assets/javascripts/discourse/components/d-editor.js.es6 b/app/assets/javascripts/discourse/components/d-editor.js.es6 index 1fcb1b76162..c4cc4f88a32 100644 --- a/app/assets/javascripts/discourse/components/d-editor.js.es6 +++ b/app/assets/javascripts/discourse/components/d-editor.js.es6 @@ -301,6 +301,9 @@ export default Ember.Component.extend({ $editorInput.autocomplete({ template: template, key: ":", + afterComplete(text) { + self.set('value', text); + }, transformComplete(v) { if (v.code) { diff --git a/app/assets/javascripts/discourse/lib/autocomplete.js.es6 b/app/assets/javascripts/discourse/lib/autocomplete.js.es6 index 5de68382117..0d158734bd5 100644 --- a/app/assets/javascripts/discourse/lib/autocomplete.js.es6 +++ b/app/assets/javascripts/discourse/lib/autocomplete.js.es6 @@ -146,6 +146,10 @@ export default function(options) { text = text.substring(0, completeStart) + (options.key || "") + term + ' ' + text.substring(completeEnd + 1, text.length); me.val(text); Discourse.Utilities.setCaretPosition(me[0], completeStart + 1 + term.length); + + if (options && options.afterComplete) { + options.afterComplete(text); + } } } } diff --git a/app/assets/javascripts/discourse/templates/discovery.hbs b/app/assets/javascripts/discourse/templates/discovery.hbs index 1e4548bbe26..069be994bad 100644 --- a/app/assets/javascripts/discourse/templates/discovery.hbs +++ b/app/assets/javascripts/discourse/templates/discovery.hbs @@ -27,3 +27,5 @@ + +{{plugin-outlet "discovery-below"}}