Skip to content

Commit 018d29d

Browse files
authored
Merge pull request #21 from dommilosz/main
fix duplicate text on pasting
2 parents 3016189 + d5dd143 commit 018d29d

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

islands/KittyPrinter.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useReducer } from "preact/hooks";
1+
import { useEffect, useReducer, useState } from "preact/hooks";
22
import { DEF_PIC_URL, STUFF_STOREKEY } from "../common/constants.ts";
33
import { _, i18nReady } from "../common/i18n.tsx";
44
import { Icons } from "../common/icons.tsx";
@@ -113,12 +113,16 @@ export default function KittyPrinter(props: KittyPrinterProps) {
113113
});
114114
});
115115
});
116+
116117
useEffect(() => {
117118
document.addEventListener('paste', () => {
118-
dispatch({
119-
action: 'add',
120-
stuff: { type: 'text', id: 0, triggerPaste: true }
121-
});
119+
if(document.activeElement.type !== "textarea"){
120+
dispatch({
121+
action: 'add',
122+
stuff: { type: 'text', id: 0, triggerPaste: true }
123+
});
124+
}
125+
122126
})
123127
}, []);
124128
const comp = <div class="kitty-container">

0 commit comments

Comments
 (0)