🐛 Fix ctrl+z in workspace select issue

This commit is contained in:
Aitor 2023-07-26 14:16:01 +02:00 committed by Alejandro Alonso
parent cc682a382f
commit f1cf5d8ba8
10 changed files with 37 additions and 20 deletions

View file

@ -17,17 +17,20 @@ if (Mousetrap.addKeycodes) {
const target = Mousetrap.prototype || Mousetrap;
target.stopCallback = function(e, element, combo) {
// if the element has the class "mousetrap" then no need to stop
if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) {
return false;
// if the element has the data attribute "mousetrap-dont-stop" then no need
// to stop. It should be used like <div data-mousetrap-dont-stop>...</div>
// or :div {:data-mousetrap-dont-stop true}
if ('mousetrapDontStop' in element.dataset) {
return false
}
// stop for input, select, textarea and button
return element.tagName == 'INPUT' ||
element.tagName == 'SELECT' ||
element.tagName == 'TEXTAREA' ||
(element.tagName == 'BUTTON' && combo.includes("tab")) ||
(element.contentEditable && element.contentEditable == 'true');
const shouldStop = element.tagName == "INPUT" ||
element.tagName == "SELECT" ||
element.tagName == "TEXTAREA" ||
(element.tagName == "BUTTON" && combo.includes("tab")) ||
(element.contentEditable && element.contentEditable == "true");
return shouldStop;
}
export default Mousetrap;