Skip to content

Commit

Permalink
feat: shortcut for sending button
Browse files Browse the repository at this point in the history
  • Loading branch information
Bin-Huang committed Mar 9, 2023
1 parent f5b963b commit 8e218c4
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/devtools/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,15 @@ function MessageInput(props: {
onSubmit: (newMsg: Message) => void
}) {
const [messageText, setMessageText] = useState<string>('')
const submit = (event?: any) => {
if (event) {
event.preventDefault()
}
props.onSubmit(createMessage('user', messageText))
setMessageText('')
}
return (
<form
onSubmit={(event) => {
event.preventDefault()
props.onSubmit(createMessage('user', messageText))
setMessageText('')
}}
>
<form onSubmit={submit}>
<Stack direction="row" spacing={1} alignItems="center">
<TextField
multiline
Expand All @@ -303,9 +304,18 @@ function MessageInput(props: {
fullWidth
autoFocus
id='message-input'
onKeyDown={(event) => {
if ((event.key === 'Enter' && event.ctrlKey) || (event.key === 'Enter' && event.metaKey)) {
submit()
}
}}
/>
<Button type="submit" variant="contained">
Send
<Button type="submit" variant="contained" sx={{
textTransform: 'none',
flexDirection: 'column',
}} >
<Typography variant='button'>SEND</Typography>
<Typography variant='caption' style={{opacity: 0.5}}>Ctrl↵</Typography>
</Button>
</Stack>
</form>
Expand Down

0 comments on commit 8e218c4

Please sign in to comment.