Spaces:
Sleeping
Sleeping
copilot-swe-agent[bot] ArnavSingh76533 commited on
Commit ·
74486d1
1
Parent(s): 7ce0d92
Fix keydown handler placement in NameModal
Browse filesCo-authored-by: ArnavSingh76533 <160649079+ArnavSingh76533@users.noreply.github.com>
- components/input/InputText.tsx +3 -0
- components/modal/NameModal.tsx +14 -15
components/input/InputText.tsx
CHANGED
|
@@ -9,6 +9,7 @@ interface Props {
|
|
| 9 |
required?: boolean
|
| 10 |
className?: string
|
| 11 |
icon?: any
|
|
|
|
| 12 |
}
|
| 13 |
|
| 14 |
const InputText: FC<Props> = ({
|
|
@@ -18,6 +19,7 @@ const InputText: FC<Props> = ({
|
|
| 18 |
icon,
|
| 19 |
className = "",
|
| 20 |
required = false,
|
|
|
|
| 21 |
}) => {
|
| 22 |
const inputRef = useRef<HTMLInputElement>(null)
|
| 23 |
return (
|
|
@@ -38,6 +40,7 @@ const InputText: FC<Props> = ({
|
|
| 38 |
type={"text"}
|
| 39 |
required={required}
|
| 40 |
onFocus={() => inputRef.current?.select()}
|
|
|
|
| 41 |
/>
|
| 42 |
{value && (
|
| 43 |
<div className={"p-2 cursor-pointer hover:text-red-400 transition-colors"} onClick={() => onChange("")}>
|
|
|
|
| 9 |
required?: boolean
|
| 10 |
className?: string
|
| 11 |
icon?: any
|
| 12 |
+
onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void
|
| 13 |
}
|
| 14 |
|
| 15 |
const InputText: FC<Props> = ({
|
|
|
|
| 19 |
icon,
|
| 20 |
className = "",
|
| 21 |
required = false,
|
| 22 |
+
onKeyDown,
|
| 23 |
}) => {
|
| 24 |
const inputRef = useRef<HTMLInputElement>(null)
|
| 25 |
return (
|
|
|
|
| 40 |
type={"text"}
|
| 41 |
required={required}
|
| 42 |
onFocus={() => inputRef.current?.select()}
|
| 43 |
+
onKeyDown={onKeyDown}
|
| 44 |
/>
|
| 45 |
{value && (
|
| 46 |
<div className={"p-2 cursor-pointer hover:text-red-400 transition-colors"} onClick={() => onChange("")}>
|
components/modal/NameModal.tsx
CHANGED
|
@@ -36,21 +36,20 @@ const NameModal: FC<Props> = ({ show, onSubmit }) => {
|
|
| 36 |
Please enter your name to join this room. This will be your display name visible to other participants.
|
| 37 |
</p>
|
| 38 |
<div>
|
| 39 |
-
<
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
</div>
|
| 54 |
{error && (
|
| 55 |
<p className="text-red-500 text-sm mt-2">{error}</p>
|
| 56 |
)}
|
|
|
|
| 36 |
Please enter your name to join this room. This will be your display name visible to other participants.
|
| 37 |
</p>
|
| 38 |
<div>
|
| 39 |
+
<InputText
|
| 40 |
+
value={name}
|
| 41 |
+
placeholder="Your display name"
|
| 42 |
+
onChange={(value) => {
|
| 43 |
+
setName(value)
|
| 44 |
+
setError("")
|
| 45 |
+
}}
|
| 46 |
+
onKeyDown={(e) => {
|
| 47 |
+
if (e.key === "Enter") {
|
| 48 |
+
handleSubmit()
|
| 49 |
+
}
|
| 50 |
+
}}
|
| 51 |
+
required
|
| 52 |
+
/>
|
|
|
|
| 53 |
{error && (
|
| 54 |
<p className="text-red-500 text-sm mt-2">{error}</p>
|
| 55 |
)}
|