Skip to content

Commit

Permalink
Fix Copy-Paste from a text control also duplicates the node #352
Browse files Browse the repository at this point in the history
  • Loading branch information
newcat committed Jan 1, 2024
1 parent d6bc70c commit b772527
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
6 changes: 6 additions & 0 deletions packages/renderer-vue/src/commands/hotkeyHandler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { ref } from "vue";

const INPUT_ELEMENT_TAGS = ["INPUT", "TEXTAREA", "SELECT"];

export function useHotkeyHandler(executeCommand: (name: string) => void) {
const pressedKeys = ref<string[]>([]);
const handlers = ref<Array<{ keys: string[]; commandName: string }>>([]);
Expand All @@ -9,6 +11,10 @@ export function useHotkeyHandler(executeCommand: (name: string) => void) {
pressedKeys.value.push(ev.key);
}

if (INPUT_ELEMENT_TAGS.includes(document.activeElement?.tagName ?? "")) {
return;
}

handlers.value.forEach((h) => {
if (h.keys.every((k) => pressedKeys.value.includes(k))) {
executeCommand(h.commandName);
Expand Down
1 change: 0 additions & 1 deletion packages/renderer-vue/src/node/Node.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
placeholder="Node Name"
@blur="doneRenaming"
@keydown.enter="doneRenaming"
@keydown.delete.stop
/>
</div>
</slot>
Expand Down
8 changes: 1 addition & 7 deletions packages/renderer-vue/src/sidebar/Sidebar.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
<template>
<div
ref="el"
class="baklava-sidebar"
:class="{ '--open': graph.sidebar.visible }"
:style="styles"
@keydown.delete.stop
>
<div ref="el" class="baklava-sidebar" :class="{ '--open': graph.sidebar.visible }" :style="styles">
<div v-if="resizable" class="__resizer" @mousedown="startResize" />

<div class="__header">
Expand Down

0 comments on commit b772527

Please sign in to comment.