Skip to content

Commit 901f1b7

Browse files
committed
fix some focus issues caused by previus chat bugfix
1 parent e3b67cd commit 901f1b7

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/packages/frontend/chat/message.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ export default function Message(props: Readonly<Props>) {
195195
}) != null
196196
);
197197
});
198+
const [autoFocusReply, setAutoFocusReply] = useState<boolean>(false);
199+
const [autoFocusEdit, setAutoFocusEdit] = useState<boolean>(false);
198200

199201
const replyMessageRef = useRef<string>("");
200202
const replyMentionsRef = useRef<SubmitMentionsFn>();
@@ -318,6 +320,7 @@ export default function Message(props: Readonly<Props>) {
318320
return;
319321
}
320322
props.actions.set_editing(message, true);
323+
setAutoFocusEdit(true);
321324
props.scroll_into_view();
322325
}
323326

@@ -579,7 +582,7 @@ export default function Message(props: Readonly<Props>) {
579582
return (
580583
<div>
581584
<ChatInput
582-
autoFocus
585+
autoFocus={autoFocusEdit}
583586
cacheId={`${props.path}${props.project_id}${date}`}
584587
input={newest_content(message)}
585588
submitMentionsRef={submitMentionsRef}
@@ -633,7 +636,7 @@ export default function Message(props: Readonly<Props>) {
633636
return (
634637
<div style={{ marginLeft: mode === "standalone" ? "30px" : "0" }}>
635638
<ChatInput
636-
autoFocus
639+
autoFocus={autoFocusReply}
637640
style={{
638641
borderRadius: "8px",
639642
height: "auto" /* for some reason the default 100% breaks things */,
@@ -655,6 +658,7 @@ export default function Message(props: Readonly<Props>) {
655658
/>
656659
<div style={{ margin: "5px 0" }}>
657660
<Button
661+
style={{ marginRight: "5px" }}
658662
onClick={() => {
659663
setReplying(false);
660664
props.actions?.syncdb?.delete({
@@ -666,12 +670,8 @@ export default function Message(props: Readonly<Props>) {
666670
>
667671
Cancel
668672
</Button>
669-
<Button
670-
onClick={sendReply}
671-
type="primary"
672-
style={{ marginRight: "5px" }}
673-
>
674-
<Icon name="paper-plane" /> Send Reply
673+
<Button onClick={sendReply} type="primary">
674+
Send Reply
675675
</Button>
676676
<LLMCostEstimationChat
677677
llm_cost={llm_cost_reply}
@@ -734,7 +734,10 @@ export default function Message(props: Readonly<Props>) {
734734
>
735735
<Button
736736
type="text"
737-
onClick={() => setReplying(true)}
737+
onClick={() => {
738+
setReplying(true);
739+
setAutoFocusReply(true);
740+
}}
738741
style={{ color: COLORS.GRAY_M }}
739742
>
740743
<Icon name="reply" /> Reply

0 commit comments

Comments
 (0)