From: Alexander Ebert Date: Mon, 22 Jul 2019 12:45:14 +0000 (+0200) Subject: Prevent the handling of clicks outside of smilies X-Git-Tag: 5.2.0_Alpha_3~21 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f3a2d1b1c1e0424586f09e48c456f700e4b2a53f;p=GitHub%2FWoltLab%2FWCF.git Prevent the handling of clicks outside of smilies --- diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Smiley/Insert.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Smiley/Insert.js index 8f83f1efb6..cccd1340a2 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Smiley/Insert.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Smiley/Insert.js @@ -12,6 +12,7 @@ define(['EventHandler', 'EventKey'], function (EventHandler, EventKey) { function UiSmileyInsert(editorId) { this.init(editorId); } UiSmileyInsert.prototype = { + _container: null, _editorId: '', /** @@ -20,17 +21,17 @@ define(['EventHandler', 'EventKey'], function (EventHandler, EventKey) { init: function (editorId) { this._editorId = editorId; - var container = elById('smilies-' + this._editorId); - if (!container) { + this._container = elById('smilies-' + this._editorId); + if (!this._container) { // form builder - container = elById(this._editorId + 'SmiliesTabContainer'); - if (!container) { + this._container = elById(this._editorId + 'SmiliesTabContainer'); + if (!this._container) { throw new Error('Unable to find the message tab menu container containing the smilies.'); } } - container.addEventListener('keydown', this._keydown.bind(this)); - container.addEventListener('mousedown', this._mousedown.bind(this)); + this._container.addEventListener('keydown', this._keydown.bind(this)); + this._container.addEventListener('mousedown', this._mousedown.bind(this)); }, /** @@ -79,6 +80,10 @@ define(['EventHandler', 'EventKey'], function (EventHandler, EventKey) { * @protected */ _mousedown: function (event) { + if (!this._container.contains(event.target)) { + return; + } + event.preventDefault(); // Clicks may occur on a few different elements, but we are only looking for the image.