Skip to content

Commit

Permalink
chore(tool-manager): make palette click detection fail safe
Browse files Browse the repository at this point in the history
  • Loading branch information
nikku authored and fake-join[bot] committed Dec 16, 2020
1 parent 0d1a2ad commit 5a1454e
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions lib/features/tool-manager/ToolManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ ToolManager.prototype.bindEvents = function(name, events) {
});

eventBus.on(eventsToRegister, LOW_PRIORITY, function(event) {
var originalEvent = event.originalEvent;

// We defer the de-activation of the tool to the .activate phase,
// so we're able to check if we want to toggle off the current
Expand All @@ -92,10 +91,27 @@ ToolManager.prototype.bindEvents = function(name, events) {
return;
}

if (originalEvent && domClosest(originalEvent.target, '.group[data-group="tools"]')) {
if (isPaletteClick(event)) {
return;
}

this.setActive(null);
}, this);

};


// helpers ///////////////

/**
* Check if a given event is a palette click event.
*
* @param {EventBus.Event} event
*
* @return {boolean}
*/
function isPaletteClick(event) {
var target = event.originalEvent && event.originalEvent.target;

return target && domClosest(target, '.group[data-group="tools"]');
}

0 comments on commit 5a1454e

Please sign in to comment.