Support Shift+Enter for newlines in chat input

The chat field was a single-line <input>, unable to hold a line
break. Switch it to an auto-growing <textarea>: plain Enter still
sends, Shift+Enter inserts a newline.
This commit is contained in:
Moepchi committed 2026-08-02 13:55:23 +02:00
1 parent 69b256eb42
commit af3a7c97cf
2 files changed
+22 -3

No files matched your search

+5 -1
View File
@@ -645,14 +645,18 @@
border-top: 1px solid var(--border-soft);
}
.ts-chat-input-row input {
.ts-chat-input-row textarea {
flex: 1;
border: 1px solid var(--border);
border-radius: 2px;
padding: 0.3rem 0.5rem;
font-size: 12px;
font-family: inherit;
background: var(--input-bg);
color: var(--input-text);
resize: none;
max-height: 8.5em;
overflow-y: auto;
}
.ts-chat-input-row button {
+17 -2
View File
@@ -1399,6 +1399,7 @@ function AppInner() {
const [chat, setChat] = useState<ChatEntry[]>([]);
const [serverChat, setServerChat] = useState<ChatEntry[]>([]);
const [chatInput, setChatInput] = useState("");
const chatInputRef = useRef<HTMLTextAreaElement>(null);
const [pmThreads, setPmThreads] = useState<Record<number, PmThread>>({});
const [pokes, setPokes] = useState<PokeNotice[]>([]);
const [pokeTarget, setPokeTarget] = useState<{ id: number; name: string } | null>(null);
@@ -2092,6 +2093,13 @@ function AppInner() {
const handleSelectItem = (item: SelectedItem) => setSelected(item);
useEffect(() => {
const el = chatInputRef.current;
if (!el) return;
el.style.height = "auto";
el.style.height = `${el.scrollHeight}px`;
}, [chatInput]);
const handleSendChat = () => {
const message = chatInput.trim();
if (!message) return;
@@ -2695,10 +2703,17 @@ function AppInner() {
))}
</div>
<div className="ts-chat-input-row">
<input
<textarea
ref={chatInputRef}
rows={1}
value={chatInput}
onChange={(e) => setChatInput(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && handleSendChat()}
onKeyDown={(e) => {
if (e.key === "Enter" && !e.shiftKey) {
e.preventDefault();
handleSendChat();
}
}}
disabled={!connected}
placeholder={
!connected