From 3cee773de0e55da5b888a08895660dce1582f04c Mon Sep 17 00:00:00 2001 From: Pierre Date: Fri, 20 Apr 2018 16:52:17 +0200 Subject: [PATCH] Make emoji picker close automatically if input parent element is destroyed --- assets/3rdparty/wdt-emoji/wdt-emoji-bundle.js | 14 ++++++++++++ assets/js/common/utils.js | 22 ++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/assets/3rdparty/wdt-emoji/wdt-emoji-bundle.js b/assets/3rdparty/wdt-emoji/wdt-emoji-bundle.js index 56c0e45c..4bd8136e 100644 --- a/assets/3rdparty/wdt-emoji/wdt-emoji-bundle.js +++ b/assets/3rdparty/wdt-emoji/wdt-emoji-bundle.js @@ -289,6 +289,20 @@ addClass(this, 'wdt-emoji-picker-open'); //this.innerHTML = wdtEmojiBundle.emoji.replace_colons(':sunglasses:'); //COMUNIC - EDIT + + + //COMUNIC EDIT + //Make the picker close automatically if the parent element is removed + var interval = setInterval(function(){ + if(!parent.isConnected){ + wdtEmojiBundle.close(); + clearInterval(interval); + } + + }, 2500); + //END COMUNIC EDIT + + }; /** diff --git a/assets/js/common/utils.js b/assets/js/common/utils.js index 2c2a1405..b00225c7 100644 --- a/assets/js/common/utils.js +++ b/assets/js/common/utils.js @@ -445,4 +445,24 @@ window.location.changed = function(e){}; window.location.changed(window.location); } }, 900); -})(); \ No newline at end of file +})(); + + +/** + * jQuery special event that detects the deletion + * of a DOM element + * + * @source StackOverFlow answer from mtkopone + */ +(function($){ + + $.event.special.destroyed = { + + remove: function(o){ + if(o.handler) + o.handler(); + } + + } + +})(jQuery); \ No newline at end of file