Fix pasting not working #551
authorAjay Bura <ajbura@gmail.com>
Sat, 14 May 2022 02:54:21 +0000 (08:24 +0530)
committerAjay Bura <ajbura@gmail.com>
Sat, 14 May 2022 02:54:21 +0000 (08:24 +0530)
src/client/event/hotkeys.js
src/client/state/navigation.js

index 30594e4842ab1d71a3a020ec6e8736691e429591..ce52decf6d4014789675bfcfce43fb69a13da49c 100644 (file)
@@ -33,22 +33,22 @@ function listenKeyboard(event) {
     // open search modal
     if (event.code === 'KeyK') {
       event.preventDefault();
-      if (navigation.isRawModalVisible) {
-        return;
-      }
+      if (navigation.isRawModalVisible) return;
       openSearch();
     }
 
     // focus message field on paste
     if (event.code === 'KeyV') {
+      if (navigation.isRawModalVisible) return;
       const msgTextarea = document.getElementById('message-textarea');
+      if (document.activeElement !== msgTextarea && document.activeElement.tagName.toLowerCase() === 'input') return;
       msgTextarea?.focus();
     }
   }
 
   if (!event.ctrlKey && !event.altKey && !event.metaKey) {
     if (navigation.isRawModalVisible) return;
-    if (['text', 'textarea'].includes(document.activeElement.type)) {
+    if (document.activeElement.tagName.toLowerCase() === 'input') {
       return;
     }
 
index cc1e173124d1dfc9e27f93adff94981e36d33c13..019a5d318fb9ce97d53a1b2379ac7419a387f537 100644 (file)
@@ -14,7 +14,8 @@ class Navigation extends EventEmitter {
     this.isRoomSettings = false;
     this.recentRooms = [];
 
-    this.isRawModalVisible = false;
+    this.rawModelStack = [];
+    window.nav = this;
   }
 
   _setSpacePath(roomId) {
@@ -47,8 +48,13 @@ class Navigation extends EventEmitter {
     }
   }
 
+  get isRawModalVisible() {
+    return this.rawModelStack.length > 0;
+  }
+
   setIsRawModalVisible(visible) {
-    this.isRawModalVisible = visible;
+    if (visible) this.rawModelStack.push(true);
+    else this.rawModelStack.pop();
   }
 
   navigate(action) {