From cd22b9aad63d3f46a07c2711ff7fddab551e0e57 Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 22 Feb 2023 14:31:41 -0700 Subject: [PATCH] Slow down tab switch on drag Avoid another tab being moved underneath the cursor if the target tab has different sidebox menu width, triggering another tab switch --- api/js/framework/fw_ui.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/api/js/framework/fw_ui.js b/api/js/framework/fw_ui.js index b345b0ac2d..4f5f63d84f 100644 --- a/api/js/framework/fw_ui.js +++ b/api/js/framework/fw_ui.js @@ -358,10 +358,29 @@ window.egw_fw_ui_tab = function(_parent, _contHeaderDiv, _contDiv, _icon, _callb // If dragging something over the tab, activate that app var tab = this.headerDiv; - this.headerDiv.addEventListener('dragenter', (event) => { + this.headerDiv.addEventListener('dragenter', (event) => + { event.stopPropagation(); - tab._callbackObject.call(tab); + if (!this.headerDiv.parentElement.dataset.dragblock) + { + this.headerDiv.parentElement.dataset.dragblock = true; + tab._callbackObject.call(tab); + } + tab.parentElement.addEventListener("dragend", dragBlockEnd) + tab.parentElement.addEventListener("dragleave", dragBlockEnd) }); + var dragBlockEnd = (e) => + { + + + tab.parentElement.removeEventListener("dragend", dragBlockEnd); + tab.parentElement.removeEventListener("dragleave", dragBlockEnd); + window.clearTimeout(tab.parentElement.dataset.dragblock); + tab.parentElement.dataset.dragblock = window.setTimeout(() => + { + tab.parentElement.removeAttribute("data-dragblock"); + }, 100); + } //Create the close button and append it to the header div