this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Autofocus on chat form and stop disabling textarea

+11 -8
+11 -8
apps/web/src/components/chat-form.tsx
··· 37 37 <form 38 38 onSubmit={(event) => { 39 39 event.preventDefault(); 40 - sendMessage.mutate( 41 - { chatId, characterId: selectedCharacterId, text }, 42 - { 43 - onSettled: () => setText(""), 44 - }, 45 - ); 40 + if (isDisabled) return; 41 + sendMessage.mutate({ chatId, characterId: selectedCharacterId, text }); 42 + setText(""); 46 43 }} 47 44 className={className} 48 45 > 49 46 <Stack gap="sm"> 50 47 <Textarea 48 + autoFocus 51 49 placeholder="Write your message here..." 52 50 className="wrap-anywhere min-h-25 focus-visible:border-transparent focus-visible:ring-0" 53 51 value={text} 54 52 onChange={(event) => setText(event.currentTarget.value)} 55 - disabled={sendMessage.isPending} 53 + onKeyDown={(event) => { 54 + if (event.key === "Enter" && !event.shiftKey) { 55 + event.preventDefault(); 56 + event.currentTarget.form?.requestSubmit(); 57 + } 58 + }} 56 59 /> 57 60 <Row justify="between" items="end"> 58 61 <CharacterSelect ··· 65 68 disabled={sendMessage.isPending || Boolean(chatId)} 66 69 /> 67 70 <Button type="submit" size="lg" disabled={isDisabled}> 68 - {sendMessage.isPending ? "Sending" : "Send"} 71 + Send 69 72 <SendIcon /> 70 73 </Button> 71 74 </Row>