Skip to content

Commit

Permalink
pressing enter auto sends
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiawei-Liao committed Oct 11, 2024
1 parent daed6c8 commit 67390c1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions frontend/src/manager-components/messaging/MessageBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import React from 'react'
import { Paper, TextField, Button, Box } from '@mui/material'

function MessageBox({ message, setMessage, HandleMessagesPush }) {
function handleKeyPress(e) {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault()
HandleMessagesPush()
}
}

return (
<Paper sx={{ padding: 2, margin: 2, width: '100%' }}>
<Box sx={{ display: 'flex', alignItems: 'center' }}>
Expand All @@ -11,6 +18,7 @@ function MessageBox({ message, setMessage, HandleMessagesPush }) {
label='message'
value={message}
onChange={(e) => setMessage(e.target.value)}
onKeyDown={handleKeyPress}
fullWidth
multiline
rows={1}
Expand Down

0 comments on commit 67390c1

Please sign in to comment.