Explorar o código

Merge pull request #2634 from weseek/fix/2622-cannot-copy-on-mac

invoke preventDefault only when stroke is completed
Yuki Takei %!s(int64=5) %!d(string=hai) anos
pai
achega
40cc3ed1c0
Modificáronse 1 ficheiros con 4 adicións e 2 borrados
  1. 4 2
      src/client/js/components/Hotkeys/HotkeysDetector.jsx

+ 4 - 2
src/client/js/components/Hotkeys/HotkeysDetector.jsx

@@ -44,12 +44,14 @@ const HotkeysDetector = (props) => {
    * evaluate the key user pressed and trigger onDetected
    */
   const checkHandler = useCallback((event) => {
-    event.preventDefault();
-
     const eventKey = getKeyExpression(event);
 
     hotkeyStrokes.forEach((hotkeyStroke) => {
+      // if any stroke is completed
       if (hotkeyStroke.evaluate(eventKey)) {
+        // cancel the key event
+        event.preventDefault();
+        // invoke detected handler
         onDetected(hotkeyStroke.stroke);
       }
     });