diff options
| author | Shoubhit Dash <[email protected]> | 2026-04-02 14:44:05 +0530 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-04-02 17:14:05 +0800 |
| commit | d540d363a76909c9c1b1d4e4113a1b8fea62c5a8 (patch) | |
| tree | 76143602c2733161100d817a58c4cb5b93730c7d /packages/ui/src/components/line-comment.tsx | |
| parent | db938913736600ce3ad68d89a9a3532c4cd517f5 (diff) | |
| download | opencode-d540d363a76909c9c1b1d4e4113a1b8fea62c5a8.tar.gz opencode-d540d363a76909c9c1b1d4e4113a1b8fea62c5a8.zip | |
refactor: simplify solid reactivity across app and web (#20497)
Diffstat (limited to 'packages/ui/src/components/line-comment.tsx')
| -rw-r--r-- | packages/ui/src/components/line-comment.tsx | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/packages/ui/src/components/line-comment.tsx b/packages/ui/src/components/line-comment.tsx index f0e29a485..26e763bb3 100644 --- a/packages/ui/src/components/line-comment.tsx +++ b/packages/ui/src/components/line-comment.tsx @@ -1,6 +1,6 @@ import { useFilteredList } from "@opencode-ai/ui/hooks" import { getDirectory, getFilename } from "@opencode-ai/util/path" -import { createEffect, createSignal, For, onMount, Show, splitProps, type JSX } from "solid-js" +import { createSignal, For, onMount, Show, splitProps, type JSX } from "solid-js" import { Button } from "./button" import { FileIcon } from "./file-icon" import { Icon } from "./icon" @@ -210,7 +210,6 @@ export const LineCommentEditor = (props: LineCommentEditorProps) => { const refs = { textarea: undefined as HTMLTextAreaElement | undefined, } - const [text, setText] = createSignal(split.value) const [open, setOpen] = createSignal(false) function selectMention(item: { path: string } | undefined) { @@ -220,10 +219,9 @@ export const LineCommentEditor = (props: LineCommentEditorProps) => { const query = currentMention() if (!textarea || !query) return - const value = `${text().slice(0, query.start)}@${item.path} ${text().slice(query.end)}` + const value = `${textarea.value.slice(0, query.start)}@${item.path} ${textarea.value.slice(query.end)}` const cursor = query.start + item.path.length + 2 - setText(value) split.onInput(value) closeMention() @@ -257,10 +255,6 @@ export const LineCommentEditor = (props: LineCommentEditorProps) => { fn() } - createEffect(() => { - setText(split.value) - }) - const closeMention = () => { setOpen(false) mention.clear() @@ -302,7 +296,7 @@ export const LineCommentEditor = (props: LineCommentEditorProps) => { } const submit = () => { - const value = text().trim() + const value = split.value.trim() if (!value) return split.onSubmit(value) } @@ -322,10 +316,9 @@ export const LineCommentEditor = (props: LineCommentEditorProps) => { data-slot="line-comment-textarea" rows={split.rows ?? 3} placeholder={split.placeholder ?? i18n.t("ui.lineComment.placeholder")} - value={text()} + value={split.value} on:input={(e) => { const value = (e.currentTarget as HTMLTextAreaElement).value - setText(value) split.onInput(value) syncMention() }} @@ -422,7 +415,7 @@ export const LineCommentEditor = (props: LineCommentEditorProps) => { type="button" data-slot="line-comment-action" data-variant="primary" - disabled={text().trim().length === 0} + disabled={split.value.trim().length === 0} on:mousedown={hold as any} on:click={click(submit) as any} > @@ -434,7 +427,7 @@ export const LineCommentEditor = (props: LineCommentEditorProps) => { <Button size="small" variant="ghost" onClick={split.onCancel}> {split.cancelLabel ?? i18n.t("ui.common.cancel")} </Button> - <Button size="small" variant="primary" disabled={text().trim().length === 0} onClick={submit}> + <Button size="small" variant="primary" disabled={split.value.trim().length === 0} onClick={submit}> {split.submitLabel ?? i18n.t("ui.lineComment.submit")} </Button> </Show> |
