From 68ff9257d9c2a660c4b31e5570ea7dba476ecd3e Mon Sep 17 00:00:00 2001 From: Bendixx Date: Thu, 21 Aug 2025 14:55:42 +0200 Subject: [PATCH 01/14] Changed all hotkeys combinations to alt+ctrl and added info in tooltip for all functions available for hotkeys shortcuts --- .../content/ConversationContent.tsx | 23 +++++++------ .../content/chat/suggestions/BobSuggests.tsx | 11 +++--- src/components/header/Header.tsx | 5 +-- src/components/inputfield/InputField.tsx | 7 ++-- src/components/menu/NewButton.tsx | 5 +-- .../menu/darkmode/DarkModeToggle.tsx | 34 ++++++++++--------- .../notification/NotificationDrawer.tsx | 5 +-- 7 files changed, 50 insertions(+), 40 deletions(-) diff --git a/src/components/content/ConversationContent.tsx b/src/components/content/ConversationContent.tsx index 969ee39..ba304d7 100644 --- a/src/components/content/ConversationContent.tsx +++ b/src/components/content/ConversationContent.tsx @@ -2,8 +2,9 @@ import { useParams, useSearchParams } from "react-router" import { useSendMessage } from "../../api/sse.ts" import { ArrowDownIcon } from "@navikt/aksel-icons" -import { Alert as AlertComponent, Button, Heading } from "@navikt/ds-react" +import { Alert as AlertComponent, Button, Heading, Tooltip } from "@navikt/ds-react" import { useEffect, useLayoutEffect, useRef, useState } from "react" +import { useHotkeys } from "react-hotkeys-hook" import Markdown from "react-markdown" import { useAlerts, useMessages } from "../../api/api.ts" import { NewMessage } from "../../types/Message.ts" @@ -107,7 +108,7 @@ function ConversationContent() { }) } - // useHotkeys("ctrl+b", () => scrollToBottom()) + useHotkeys("alt+ctrl+b", () => scrollToBottom()) return (
@@ -129,14 +130,16 @@ function ConversationContent() { )}
{showScrollButton && ( - - - - From 05a4575b2c178c8f1cb986468a316f4de10815da Mon Sep 17 00:00:00 2001 From: Bendixx Date: Fri, 22 Aug 2025 10:31:26 +0200 Subject: [PATCH 04/14] removed alt+ctrl for all hotkeys and changed tooltip description + added aria-label --- src/components/content/ConversationContent.tsx | 5 +++-- .../content/chat/suggestions/BobSuggests.tsx | 10 +++++----- src/components/header/Header.tsx | 5 +++-- src/components/inputfield/InputField.tsx | 8 ++++---- src/components/menu/NewButton.tsx | 6 ++++-- src/components/menu/darkmode/DarkModeToggle.tsx | 6 ++++-- src/components/notification/NotificationDrawer.tsx | 5 +++-- 7 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/components/content/ConversationContent.tsx b/src/components/content/ConversationContent.tsx index ba304d7..17e0330 100644 --- a/src/components/content/ConversationContent.tsx +++ b/src/components/content/ConversationContent.tsx @@ -108,7 +108,7 @@ function ConversationContent() { }) } - useHotkeys("alt+ctrl+b", () => scrollToBottom()) + useHotkeys("B", () => scrollToBottom()) return (
@@ -130,7 +130,7 @@ function ConversationContent() { )}
{showScrollButton && ( - + - - - From 965bd717b2f9242bc9c164367879b1dc2855b900 Mon Sep 17 00:00:00 2001 From: Bendixx Date: Fri, 22 Aug 2025 10:31:26 +0200 Subject: [PATCH 11/14] removed alt+ctrl for all hotkeys and changed tooltip description + added aria-label --- src/components/content/ConversationContent.tsx | 5 +++-- .../content/chat/suggestions/BobSuggests.tsx | 10 +++++----- src/components/header/Header.tsx | 5 +++-- src/components/inputfield/InputField.tsx | 8 ++++---- src/components/menu/NewButton.tsx | 6 ++++-- src/components/menu/darkmode/DarkModeToggle.tsx | 6 ++++-- src/components/notification/NotificationDrawer.tsx | 5 +++-- 7 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/components/content/ConversationContent.tsx b/src/components/content/ConversationContent.tsx index ba304d7..17e0330 100644 --- a/src/components/content/ConversationContent.tsx +++ b/src/components/content/ConversationContent.tsx @@ -108,7 +108,7 @@ function ConversationContent() { }) } - useHotkeys("alt+ctrl+b", () => scrollToBottom()) + useHotkeys("B", () => scrollToBottom()) return (
@@ -130,7 +130,7 @@ function ConversationContent() { )}
{showScrollButton && ( - + - @@ -123,9 +123,18 @@ export const Step1 = ({
- - - + + + Om tjenesten @@ -187,9 +205,18 @@ export const Step2 = ({
- - - + + + Når du stiller spørsmål - @@ -252,9 +289,18 @@ export const Step3 = ({
- - - + + + Om svaret fra Bob - @@ -319,9 +376,19 @@ export const Step4 = ({
- - - + + + Misfornøyd med svaret? Prøv dette: - diff --git a/src/components/header/Header.tsx b/src/components/header/Header.tsx index e542c91..40cd7c8 100644 --- a/src/components/header/Header.tsx +++ b/src/components/header/Header.tsx @@ -30,7 +30,9 @@ function Header({ conversation }: HeaderProps) { setStartGuide(true) } - useHotkeys("Alt+Ctrl+I", () => showGuide()) + useHotkeys("Alt+Ctrl+I", () => showGuide(), { + enableOnFormTags: true, + }) return (
diff --git a/src/components/inputfield/InputField.tsx b/src/components/inputfield/InputField.tsx index a6dbf77..c5e328c 100644 --- a/src/components/inputfield/InputField.tsx +++ b/src/components/inputfield/InputField.tsx @@ -68,19 +68,16 @@ const InputField = forwardRef(function InputFie const { alerts } = useAlerts() const hasErrors = alerts.at(0)?.notificationType === "Error" - function sendMessage(messageContent?: string) { - if (sendDisabled) { - return - } + function sendMessage(messageContent?: string, opts: { clear?: boolean; blur?: boolean } = {}) { + const { clear = true, blur = true } = opts + if (sendDisabled) return - const message: NewMessage = { - content: messageContent ?? inputValue, - } + const message: NewMessage = { content: messageContent ?? inputValue } if (message.content.trim() !== "") { onSend(message) } - setInputValue("") - textareaRef.current?.blur() + if (clear) setInputValue("") + if (blur) textareaRef.current?.blur() } function handleInputChange(e: React.ChangeEvent) { @@ -109,7 +106,6 @@ const InputField = forwardRef(function InputFie if (!sendDisabled) { analytics.meldingSendt("enter") sendMessage() - setInputValue("") setIsSensitiveInfoAlert(false) } } @@ -120,7 +116,6 @@ const InputField = forwardRef(function InputFie if (inputValue.trim() !== "") { analytics.meldingSendt("knapp") sendMessage() - setInputValue("") } } @@ -135,9 +130,18 @@ const InputField = forwardRef(function InputFie setSendDisabled(disabled || inputContainsFnr || hasErrors) }, [inputValue, disabled, hasErrors]) - useHotkeys("Alt+Ctrl+O", () => sendMessage("Oversett til engelsk"), { enabled: !!conversationId }) - useHotkeys("Alt+Ctrl+P", () => sendMessage("Gjør om svaret til punktliste"), { enabled: !!conversationId }) - useHotkeys("Alt+Ctrl+E", () => sendMessage("Gjør svaret mer empatisk"), { enabled: !!conversationId }) + useHotkeys("Alt+Ctrl+O", () => sendMessage("Oversett til engelsk", { clear: false, blur: false }), { + enabled: !!conversationId, + enableOnFormTags: true, + }) + useHotkeys("Alt+Ctrl+P", () => sendMessage("Gjør om svaret til punktliste", { clear: false, blur: false }), { + enabled: !!conversationId, + enableOnFormTags: true, + }) + useHotkeys("Alt+Ctrl+E", () => sendMessage("Gjør svaret mer empatisk", { clear: false, blur: false }), { + enabled: !!conversationId, + enableOnFormTags: true, + }) return (
primaryBtnRef.current?.focus()) }, [newConversationRef]) - useHotkeys("Alt+Ctrl+N", openModal) + useHotkeys("Alt+Ctrl+N", openModal, { + enableOnFormTags: true, + }) const startNew = () => { setInputValue("") diff --git a/src/components/menu/darkmode/DarkModeToggle.tsx b/src/components/menu/darkmode/DarkModeToggle.tsx index 1f0465c..94ba6a7 100644 --- a/src/components/menu/darkmode/DarkModeToggle.tsx +++ b/src/components/menu/darkmode/DarkModeToggle.tsx @@ -30,7 +30,9 @@ const DarkModeToggle = () => { const tooltip = dark ? "Endre til lys modus ( Alt+Ctrl+D )" : "Endre til mørk modus ( Alt+Ctrl+D )" - useHotkeys("alt+ctrl+d", () => darkModeHandler()) + useHotkeys("alt+ctrl+d", () => darkModeHandler(), { + enableOnFormTags: true, + }) return ( diff --git a/src/components/notification/NotificationDrawer.tsx b/src/components/notification/NotificationDrawer.tsx index ce7430e..7e2ec3b 100644 --- a/src/components/notification/NotificationDrawer.tsx +++ b/src/components/notification/NotificationDrawer.tsx @@ -53,7 +53,9 @@ export const NotificationToggle = () => { } }, [initialOpen, setInitialOpen, hasUnread]) - useHotkeys("Alt+Ctrl+V", () => setInitialOpen((prev) => !prev)) + useHotkeys("Alt+Ctrl+V", () => setInitialOpen((prev) => !prev), { + enableOnFormTags: true, + }) return (