From 4efcad46f38b7ee667e0ad3183e8984e2fad5737 Mon Sep 17 00:00:00 2001 From: Simon Huber Date: Mon, 20 Apr 2020 16:49:30 +0200 Subject: [PATCH] Make input fields dismiss their popups when the ... (#4579) * Make input fields dismiss their popups when the ... ... fields loose focus (`blur`) * Update simple.js --- core/modules/editor/engines/simple.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/core/modules/editor/engines/simple.js b/core/modules/editor/engines/simple.js index bb77893d7..6f6de6700 100644 --- a/core/modules/editor/engines/simple.js +++ b/core/modules/editor/engines/simple.js @@ -55,7 +55,8 @@ function SimpleEngine(options) { // Add an input event handler $tw.utils.addEventListeners(this.domNode,[ {name: "focus", handlerObject: this, handlerMethod: "handleFocusEvent"}, - {name: "input", handlerObject: this, handlerMethod: "handleInputEvent"} + {name: "input", handlerObject: this, handlerMethod: "handleInputEvent"}, + {name: "blur", handlerObject: this, handlerMethod: "handleBlurEvent"} ]); // Insert the element into the DOM this.parentNode.insertBefore(this.domNode,this.nextSibling); @@ -133,6 +134,20 @@ SimpleEngine.prototype.handleFocusEvent = function(event) { return true; }; +/* +Handle a dom "blur" event +*/ +SimpleEngine.prototype.handleBlurEvent = function(event) { + if(this.widget.editFocusPopup) { + $tw.popup.triggerPopup({ + domNode: this.domNode, + title: this.widget.editFocusPopup, + wiki: this.widget.wiki + }); + } + return true; +}; + /* Create a blank structure representing a text operation */