) => {
+ if (e.key === 'Enter' && username && roomName) {
+ handleSocket();
+ }
+ };
+
if (isWaitingForTeacher) {
return (
@@ -169,7 +175,8 @@ const JoinRoom: React.FC = () => {
onChange={(e) => setRoomName(e.target.value)}
placeholder="Numéro de la salle"
sx={{ marginBottom: '1rem' }}
- fullWidth
+ fullWidth={true}
+ onKeyDown={handleReturnKey}
/>
{
onChange={(e) => setUsername(e.target.value)}
placeholder="Nom d'utilisateur"
sx={{ marginBottom: '1rem' }}
- fullWidth
+ fullWidth={true}
+ onKeyDown={handleReturnKey}
/>
{
setValue(value);
}
- const linesArray = value.split(/(?<=^|[^\\]}.*)[\n]+/);
+ // split value when there is at least one blank line
+ const linesArray = value.split(/\n{2,}/);
+
+ // if the first item in linesArray is blank, remove it
+ if (linesArray[0] === '') linesArray.shift();
if (linesArray[linesArray.length - 1] === '') linesArray.pop();
diff --git a/client/src/pages/Teacher/Login/Login.tsx b/client/src/pages/Teacher/Login/Login.tsx
index 7c82a24..f305101 100644
--- a/client/src/pages/Teacher/Login/Login.tsx
+++ b/client/src/pages/Teacher/Login/Login.tsx
@@ -1,6 +1,4 @@
-import { useNavigate, Link } from 'react-router-dom';
-
-// JoinRoom.tsx
+import { Link, useNavigate } from 'react-router-dom';
import React, { useEffect, useState } from 'react';
import './Login.css';
@@ -38,6 +36,11 @@ const Login: React.FC = () => {
};
+ const handleReturnKey = (e: React.KeyboardEvent) => {
+ if (e.key === 'Enter' && email && password) {
+ login();
+ }
+ };
return (
{
onChange={(e) => setEmail(e.target.value)}
placeholder="Adresse courriel"
sx={{ marginBottom: '1rem' }}
- fullWidth
+ fullWidth={true}
+ onKeyDown={handleReturnKey} // Add this line as well
/>
{
onChange={(e) => setPassword(e.target.value)}
placeholder="Mot de passe"
sx={{ marginBottom: '1rem' }}
- fullWidth
+ fullWidth={true}
+ onKeyDown={handleReturnKey} // Add this line as well
/>