feat(chat): update message sending behavior and input focus management
This commit is contained in:
@@ -342,6 +342,7 @@ export default function BoardDetailPage() {
|
|||||||
const [isCommentsLoading, setIsCommentsLoading] = useState(false);
|
const [isCommentsLoading, setIsCommentsLoading] = useState(false);
|
||||||
const [commentsError, setCommentsError] = useState<string | null>(null);
|
const [commentsError, setCommentsError] = useState<string | null>(null);
|
||||||
const [newComment, setNewComment] = useState("");
|
const [newComment, setNewComment] = useState("");
|
||||||
|
const taskCommentInputRef = useRef<HTMLTextAreaElement | null>(null);
|
||||||
const [isPostingComment, setIsPostingComment] = useState(false);
|
const [isPostingComment, setIsPostingComment] = useState(false);
|
||||||
const [postCommentError, setPostCommentError] = useState<string | null>(null);
|
const [postCommentError, setPostCommentError] = useState<string | null>(null);
|
||||||
const [isDetailOpen, setIsDetailOpen] = useState(false);
|
const [isDetailOpen, setIsDetailOpen] = useState(false);
|
||||||
@@ -1713,6 +1714,7 @@ export default function BoardDetailPage() {
|
|||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
setIsPostingComment(false);
|
setIsPostingComment(false);
|
||||||
|
taskCommentInputRef.current?.focus();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2612,8 +2614,18 @@ export default function BoardDetailPage() {
|
|||||||
</p>
|
</p>
|
||||||
<div className="space-y-2 rounded-xl border border-slate-200 bg-slate-50 p-3">
|
<div className="space-y-2 rounded-xl border border-slate-200 bg-slate-50 p-3">
|
||||||
<Textarea
|
<Textarea
|
||||||
|
ref={taskCommentInputRef}
|
||||||
value={newComment}
|
value={newComment}
|
||||||
onChange={(event) => setNewComment(event.target.value)}
|
onChange={(event) => setNewComment(event.target.value)}
|
||||||
|
onKeyDown={(event) => {
|
||||||
|
if (event.key !== "Enter") return;
|
||||||
|
if (event.nativeEvent.isComposing) return;
|
||||||
|
if (event.shiftKey) return;
|
||||||
|
event.preventDefault();
|
||||||
|
if (isPostingComment) return;
|
||||||
|
if (!newComment.trim()) return;
|
||||||
|
void handlePostComment();
|
||||||
|
}}
|
||||||
placeholder="Write a message for the assigned agent…"
|
placeholder="Write a message for the assigned agent…"
|
||||||
className="min-h-[80px] bg-white"
|
className="min-h-[80px] bg-white"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -415,8 +415,9 @@ export function BoardOnboardingChat({
|
|||||||
value={extraContext}
|
value={extraContext}
|
||||||
onChange={(event) => setExtraContext(event.target.value)}
|
onChange={(event) => setExtraContext(event.target.value)}
|
||||||
onKeyDown={(event) => {
|
onKeyDown={(event) => {
|
||||||
if (!(event.ctrlKey || event.metaKey)) return;
|
|
||||||
if (event.key !== "Enter") return;
|
if (event.key !== "Enter") return;
|
||||||
|
if (event.nativeEvent.isComposing) return;
|
||||||
|
if (event.shiftKey) return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (loading) return;
|
if (loading) return;
|
||||||
void submitExtraContext();
|
void submitExtraContext();
|
||||||
@@ -434,7 +435,7 @@ export function BoardOnboardingChat({
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-xs text-slate-500">
|
<p className="text-xs text-slate-500">
|
||||||
Tip: press Ctrl+Enter (or Cmd+Enter) to send.
|
Tip: press Enter to send. Shift+Enter for a newline.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
@@ -479,15 +480,16 @@ export function BoardOnboardingChat({
|
|||||||
value={otherText}
|
value={otherText}
|
||||||
onChange={(event) => setOtherText(event.target.value)}
|
onChange={(event) => setOtherText(event.target.value)}
|
||||||
onKeyDown={(event) => {
|
onKeyDown={(event) => {
|
||||||
if (!(event.ctrlKey || event.metaKey)) return;
|
|
||||||
if (event.key !== "Enter") return;
|
if (event.key !== "Enter") return;
|
||||||
|
if (event.nativeEvent.isComposing) return;
|
||||||
|
if (event.shiftKey) return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (loading) return;
|
if (loading) return;
|
||||||
submitAnswer();
|
submitAnswer();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<p className="text-xs text-slate-500">
|
<p className="text-xs text-slate-500">
|
||||||
Tip: press Ctrl+Enter (or Cmd+Enter) to send.
|
Tip: press Enter to send. Shift+Enter for a newline.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|||||||
Reference in New Issue
Block a user