From 650ed865042a5ef1704b30a616f5c4e982670303 Mon Sep 17 00:00:00 2001 From: z1glr Date: Fri, 7 Feb 2025 12:19:56 +0000 Subject: [PATCH] added event-editor-submit through ctrl+enter in description --- client/package-lock.json | 10 ++++++++++ client/package.json | 3 ++- client/src/components/Event/EventEditor.tsx | 12 ++++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/client/package-lock.json b/client/package-lock.json index f5b8fbb..8d2a1ba 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -11,6 +11,7 @@ "@carbon/icons-react": "^11.53.0", "@heroui/react": "^2.6.14", "@internationalized/date": "3.6.0", + "@mantine/hooks": "^7.16.2", "@react-aria/i18n": "^3.12.4", "@react-stately/data": "^3.12.0", "framer-motion": "^12.0.0", @@ -2494,6 +2495,15 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@mantine/hooks": { + "version": "7.16.2", + "resolved": "https://registry.npmjs.org/@mantine/hooks/-/hooks-7.16.2.tgz", + "integrity": "sha512-ZFHQhDi9T+r6VR5NEeE47gigPPIAHVIKDOCWsCsbCqHc3yz5l8kiO2RdfUmsTKV2KD/AiXnAw4b6pjQEP58GOg==", + "license": "MIT", + "peerDependencies": { + "react": "^18.x || ^19.x" + } + }, "node_modules/@next/env": { "version": "15.1.5", "resolved": "https://registry.npmjs.org/@next/env/-/env-15.1.5.tgz", diff --git a/client/package.json b/client/package.json index 010d43b..ce87321 100644 --- a/client/package.json +++ b/client/package.json @@ -9,9 +9,10 @@ "lint": "next lint" }, "dependencies": { - "@internationalized/date": "3.6.0", "@carbon/icons-react": "^11.53.0", "@heroui/react": "^2.6.14", + "@internationalized/date": "3.6.0", + "@mantine/hooks": "^7.16.2", "@react-aria/i18n": "^3.12.4", "@react-stately/data": "^3.12.0", "framer-motion": "^12.0.0", diff --git a/client/src/components/Event/EventEditor.tsx b/client/src/components/Event/EventEditor.tsx index b564baa..708aed8 100644 --- a/client/src/components/Event/EventEditor.tsx +++ b/client/src/components/Event/EventEditor.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useRef, useState } from "react"; import { getLocalTimeZone, now, @@ -21,6 +21,7 @@ import { EventData } from "@/Zustand"; import { useAsyncList } from "@react-stately/data"; import { getTasks } from "@/lib"; import Loading from "../Loading"; +import { getHotkeyHandler } from "@mantine/hooks"; export interface EventSubmitData { eventID: number; @@ -49,6 +50,7 @@ export default function EventEditor(props: { const [eventTasks, setEventTasks] = useState( props.value?.tasks.map((k) => k.taskID.toString()) ?? [], ); + const submitButtonRef = useRef(null); const tasks = useAsyncList({ async load() { @@ -108,6 +110,9 @@ export default function EventEditor(props: { name="description" value={description} onValueChange={setDescription} + onKeyDown={getHotkeyHandler([ + ["ctrl+Enter", () => submitButtonRef.current?.click()], + ])} /> - {props.footer} + +