Prevent rogue mouseup on tab from triggering tab change

This commit is contained in:
Nick O'Leary 2021-02-17 12:03:13 +00:00
parent 785c349adc
commit 45afd06047
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -29,6 +29,7 @@ RED.tabs = (function() {
var currentTabWidth;
var currentActiveTabWidth = 0;
var collapsibleMenu;
var mousedownTab;
var preferredOrder = options.order;
var ul = options.element || $("#"+options.id);
var wrapper = ul.wrap( "<div>" ).parent();
@ -207,6 +208,11 @@ RED.tabs = (function() {
if (dragActive) {
return
}
if (evt.currentTarget !== mousedownTab) {
mousedownTab = null;
return;
}
mousedownTab = null;
if (dblClickTime && Date.now()-dblClickTime < 400) {
dblClickTime = 0;
dblClickArmed = true;
@ -445,6 +451,7 @@ RED.tabs = (function() {
}
ul.find("li.red-ui-tab a")
.on("mousedown", function(evt) { mousedownTab = evt.currentTarget })
.on("mouseup",onTabClick)
.on("click", function(evt) {evt.preventDefault(); })
.on("dblclick", function(evt) {evt.stopPropagation(); evt.preventDefault(); })
@ -636,6 +643,7 @@ RED.tabs = (function() {
}
}
link.on("mousedown", function(evt) { mousedownTab = evt.currentTarget })
link.on("mouseup",onTabClick);
link.on("click", function(evt) { evt.preventDefault(); })
link.on("dblclick", function(evt) { evt.stopPropagation(); evt.preventDefault(); })