From 22277772efb833acdc9d77c40d4a6f77b011bdad Mon Sep 17 00:00:00 2001 From: Tom Chen Date: Wed, 11 Nov 2015 22:30:21 +0800 Subject: [PATCH] fix(TCMention): add autoHideOnBlurDelay to options * closes #3 --- src/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index d50e435..da01025 100644 --- a/src/index.js +++ b/src/index.js @@ -75,6 +75,8 @@ export const TCMention = MediumEditor.Extension.extend({ "@": `medium-editor-mention-at`, }, + autoHideOnBlurDelay: 300, + init () { this.mentionPanel = this.createPanel(); @@ -82,6 +84,7 @@ export const TCMention = MediumEditor.Extension.extend({ this.subscribe(`editableKeydown`, ::this.handleKeydown); this.subscribe(`editableBlur`, ::this.handleBlur); + this.subscribe(`focus`, ::this.handleFocus); // // instance variables this.trigger = null; @@ -159,7 +162,11 @@ Your mention implementation }, handleBlur (event) { - this.hidePanel(); + this.autoHideTimeoutId = setTimeout(::this.hidePanel, this.autoHideOnBlurDelay); + }, + + handleFocus (event) { + clearTimeout(this.autoHideTimeoutId); }, handleTriggerKeydown (trigger, event) {