From 4a715bfd17fbb2cbaaeb8d5bc839ab7e8e73a036 Mon Sep 17 00:00:00 2001 From: Ajay Bura Date: Sat, 14 May 2022 08:24:21 +0530 Subject: [PATCH] Fix pasting not working #551 --- src/client/event/hotkeys.js | 8 ++++---- src/client/state/navigation.js | 10 ++++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/client/event/hotkeys.js b/src/client/event/hotkeys.js index 30594e4..ce52dec 100644 --- a/src/client/event/hotkeys.js +++ b/src/client/event/hotkeys.js @@ -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; } diff --git a/src/client/state/navigation.js b/src/client/state/navigation.js index cc1e173..019a5d3 100644 --- a/src/client/state/navigation.js +++ b/src/client/state/navigation.js @@ -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) {