From 60b427fdead5a7592af9659bead861846a41b41e Mon Sep 17 00:00:00 2001 From: the1812 Date: Mon, 12 Feb 2024 23:39:20 +0800 Subject: [PATCH] Update send comment action (fix #4612) --- registry/lib/components/utils/keymap/actions.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/registry/lib/components/utils/keymap/actions.ts b/registry/lib/components/utils/keymap/actions.ts index a3ad8d2805..7a3f6e5701 100644 --- a/registry/lib/components/utils/keymap/actions.ts +++ b/registry/lib/components/utils/keymap/actions.ts @@ -244,8 +244,18 @@ export const builtInActions: Record = { if (!activeElement || !(activeElement instanceof HTMLTextAreaElement)) { return null } - const sendButton = (activeElement.nextElementSibling ?? - activeElement.parentElement.nextElementSibling) as HTMLButtonElement + const sendButton = (() => { + const candidates = [ + () => activeElement.nextElementSibling, + () => activeElement.parentElement.nextElementSibling, + () => dq('.reply-box:focus-within .reply-box-send'), + ] + const match = candidates.find(fn => fn() !== null) + if (match) { + return match() as HTMLElement + } + return null + })() if (!sendButton) { return null }