mirror of
https://github.com/wekan/wekan.git
synced 2025-04-23 13:37:09 -04:00
Generic fix for keyboard shortcuts which fixes "SPACE" shortcut and more bugs
This commit is contained in:
parent
f1810e47e0
commit
01a717f143
1 changed files with 15 additions and 6 deletions
|
@ -14,24 +14,33 @@ window.addEventListener('keydown', (e) => {
|
|||
Mousetrap.trigger(String.fromCharCode(e.which).toLowerCase());
|
||||
});
|
||||
|
||||
// Store the original stopCallback in a global
|
||||
const originalStopCallback = Mousetrap.stopCallback;
|
||||
|
||||
// Overwrite the stopCallback to allow for more keyboard shortcut customizations
|
||||
Mousetrap.stopCallback = (e, element) => {
|
||||
Mousetrap.stopCallback = (event, element) => {
|
||||
// Are shortcuts enabled for the user?
|
||||
if (!ReactiveCache.getCurrentUser().isKeyboardShortcuts())
|
||||
return true;
|
||||
|
||||
// Always handle escape
|
||||
if (e.keyCode === 27)
|
||||
if (event.keyCode === 27)
|
||||
return false;
|
||||
|
||||
// Make sure there are no selected characters
|
||||
if (window.getSelection().type === "Range")
|
||||
return true;
|
||||
|
||||
return originalStopCallback(e, element);
|
||||
// Decide what the current element is
|
||||
const currentElement = event.target || document.activeElement;
|
||||
|
||||
// If the current element is editable, we don't want to trigger an event
|
||||
if (currentElement.isContentEditable)
|
||||
return true;
|
||||
|
||||
// Make sure we are not in an input element
|
||||
if (currentElement instanceof HTMLInputElement || currentElement instanceof HTMLSelectElement || currentElement instanceof HTMLTextAreaElement)
|
||||
return true;
|
||||
|
||||
// We can trigger events!
|
||||
return false;
|
||||
}
|
||||
|
||||
function getHoveredCardId() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue