diff --git a/packages/ui/src/components/line-comment.tsx b/packages/ui/src/components/line-comment.tsx index ff5d1df007..bc47ad9405 100644 --- a/packages/ui/src/components/line-comment.tsx +++ b/packages/ui/src/components/line-comment.tsx @@ -206,6 +206,16 @@ export const LineCommentEditor = (props: LineCommentEditorProps) => { const [text, setText] = createSignal(split.value) const focus = () => refs.textarea?.focus() + const hold: JSX.EventHandlerUnion = (e) => { + e.preventDefault() + e.stopPropagation() + } + const click = + (fn: VoidFunction): JSX.EventHandlerUnion => + (e) => { + e.stopPropagation() + fn() + } createEffect(() => { setText(split.value) @@ -268,7 +278,8 @@ export const LineCommentEditor = (props: LineCommentEditorProps) => { type="button" data-slot="line-comment-action" data-variant="ghost" - on:click={split.onCancel as any} + on:mousedown={hold as any} + on:click={click(split.onCancel) as any} > {split.cancelLabel ?? i18n.t("ui.common.cancel")} @@ -277,7 +288,8 @@ export const LineCommentEditor = (props: LineCommentEditorProps) => { data-slot="line-comment-action" data-variant="primary" disabled={text().trim().length === 0} - on:click={submit as any} + on:mousedown={hold as any} + on:click={click(submit) as any} > {split.submitLabel ?? i18n.t("ui.lineComment.submit")}