From 5a6c5f20834dcb2abafdfc921fee82e3a501d208 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 1 May 2018 15:40:44 +1000 Subject: [PATCH] FEATURE: add a delay on the "mention" warning in composer Previously we would warn too early about lack of visibility --- .../discourse/components/composer-editor.js.es6 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/components/composer-editor.js.es6 b/app/assets/javascripts/discourse/components/composer-editor.js.es6 index 43d33da68fa..86b4d39f87d 100644 --- a/app/assets/javascripts/discourse/components/composer-editor.js.es6 +++ b/app/assets/javascripts/discourse/components/composer-editor.js.es6 @@ -425,8 +425,16 @@ export default Ember.Component.extend({ let name = $e.data('name'); if (found.indexOf(name) === -1) { - this.sendAction('cannotSeeMention', [{ name: name }]); - found.push(name); + + // add a delay to allow for typing, so you don't open the warning right away + // previously we would warn after @bob even if you were about to mention @bob2 + Em.run.later(this, () => { + if ($preview.find('.mention.cannot-see[data-name="' + name + '"]').length > 0) { + this.sendAction('cannotSeeMention', [{ name: name }]); + found.push(name); + } + }, 2000); + } });