From 1fbf5d6552b60c694f6bfb0aa71d5ad02bcb8c85 Mon Sep 17 00:00:00 2001 From: ayangweb <75017711+ayangweb@users.noreply.github.com> Date: Fri, 6 Jun 2025 11:47:38 +0800 Subject: [PATCH] fix: resolved an issue where number keys were not working on the web (#616) * fix: resolved an issue where number keys were not working on the web * docs: update changelog --- docs/content.en/docs/release-notes/_index.md | 1 + scripts/devWeb.ts | 1 + src/hooks/useKeyboardNavigation.ts | 10 +++++++++- 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 scripts/devWeb.ts diff --git a/docs/content.en/docs/release-notes/_index.md b/docs/content.en/docs/release-notes/_index.md index 11ade113..9fc069bf 100644 --- a/docs/content.en/docs/release-notes/_index.md +++ b/docs/content.en/docs/release-notes/_index.md @@ -22,6 +22,7 @@ Information about release notes of Coco Server is provided here. - fix: new chat assistant id not found #603 - fix: resolve regex error on older macOS versions #605 - fix: fix chat log update and sorting issues #612 +- fix: resolved an issue where number keys were not working on the web #616 ### ✈️ Improvements diff --git a/scripts/devWeb.ts b/scripts/devWeb.ts new file mode 100644 index 00000000..1ebec891 --- /dev/null +++ b/scripts/devWeb.ts @@ -0,0 +1 @@ +(() => {})(); diff --git a/src/hooks/useKeyboardNavigation.ts b/src/hooks/useKeyboardNavigation.ts index 4b74f85c..8a421783 100644 --- a/src/hooks/useKeyboardNavigation.ts +++ b/src/hooks/useKeyboardNavigation.ts @@ -84,6 +84,8 @@ export function useKeyboardNavigation({ } if (e.key >= "0" && e.key <= "9" && showIndex && isMetaOrCtrlKey(e)) { + e.preventDefault(); + let index = parseInt(e.key, 10); index = index === 0 ? 9 : index - 1; @@ -91,7 +93,13 @@ export function useKeyboardNavigation({ const item = globalItemIndexMap[index]; if (item?.on_opened) { - platformAdapter.invokeBackend("open", { onOpened: item.on_opened }); + return platformAdapter.invokeBackend("open", { + onOpened: item.on_opened, + }); + } + + if (item?.url) { + OpenURLWithBrowser(item.url); } } },