diff --git a/components/NewInfractionModal.tsx b/components/NewInfractionModal.tsx index 3a13331..cbfa459 100644 --- a/components/NewInfractionModal.tsx +++ b/components/NewInfractionModal.tsx @@ -14,7 +14,7 @@ import { } from "@chakra-ui/react"; export default function (props: { isOpen: boolean; onClose: () => void }) { - addEventListener("paste", (e) => { + function pasteHandler(e: ClipboardEvent) { if (!props.isOpen) return; const evidenceElement = document.getElementById( @@ -38,14 +38,17 @@ export default function (props: { isOpen: boolean; onClose: () => void }) { dataTransfer.items.add(e.clipboardData.files[0]); evidenceElement.files = dataTransfer.files; - }); + } + + addEventListener("paste", pasteHandler); function reset() { + removeEventListener("paste", pasteHandler); ( document.getElementById("punishment") as unknown as HTMLSelectElement ).selectedIndex = -1; (document.getElementById("user") as HTMLInputElement).value = ""; - (document.getElementById("evidence") as HTMLInputElement).value = ""; + (document.getElementById("evidence") as HTMLInputElement).files = null; props.onClose(); } @@ -96,7 +99,13 @@ export default function (props: { isOpen: boolean; onClose: () => void }) { } return ( - + New Infraction @@ -118,7 +127,10 @@ export default function (props: { isOpen: boolean; onClose: () => void }) {

Evidence -