Skip to content

Commit

Permalink
Fix pasting not working #551
Browse files Browse the repository at this point in the history
  • Loading branch information
ajbura committed May 14, 2022
1 parent 0b70c7e commit 4a715bf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/client/event/hotkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
10 changes: 8 additions & 2 deletions src/client/state/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class Navigation extends EventEmitter {
this.isRoomSettings = false;
this.recentRooms = [];

this.isRawModalVisible = false;
this.rawModelStack = [];
window.nav = this;
}

_setSpacePath(roomId) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 4a715bf

Please sign in to comment.