From 41dba29ee4755a6971359316588c910dc8863203 Mon Sep 17 00:00:00 2001 From: Bradley Dwyer Date: Wed, 27 Nov 2024 13:50:07 +1000 Subject: [PATCH 1/8] =?UTF-8?q?feat:=20add=20=E2=8C=A5+=E2=8F=8E=20as=20a?= =?UTF-8?q?=20shortcut=20for=20the=20verb=20form?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/decls/verb/VerbFormInput.tsx | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/frontend/console/src/features/modules/decls/verb/VerbFormInput.tsx b/frontend/console/src/features/modules/decls/verb/VerbFormInput.tsx index 1432816467..fd5a2f48e7 100644 --- a/frontend/console/src/features/modules/decls/verb/VerbFormInput.tsx +++ b/frontend/console/src/features/modules/decls/verb/VerbFormInput.tsx @@ -1,5 +1,6 @@ import { Copy01Icon } from 'hugeicons-react' import { Button } from '../../../../components/Button' +import {useEffect, useRef} from "react"; export const VerbFormInput = ({ requestType, @@ -18,13 +19,29 @@ export const VerbFormInput = ({ onSubmit: (path: string) => void handleCopyButton?: () => void }) => { + const formRef = useRef(null) + const handleSubmit: React.FormEventHandler = async (event) => { event.preventDefault() onSubmit(path) } + useEffect(() => { + const handleGlobalKeyDown = (event: KeyboardEvent) => { + if (event.altKey && event.key === 'Enter') { + event.preventDefault() + formRef.current?.dispatchEvent(new Event('submit', { cancelable: true, bubbles: true })) + } + } + + document.addEventListener('keydown', handleGlobalKeyDown) + return () => { + document.removeEventListener('keydown', handleGlobalKeyDown) + } + }, [path, readOnly, onSubmit]) + return ( -
+
{requestType} @@ -38,7 +55,7 @@ export const VerbFormInput = ({ readOnly={readOnly} onChange={(event) => setPath(event.target.value)} /> -