Updated nickname modal to focus input by default
This commit is contained in:
parent
5c0272fc2d
commit
8ba3881529
@ -1,4 +1,4 @@
|
|||||||
import React from "react";
|
import React, { useRef } from "react";
|
||||||
import { Box, Input, Button, Label, Flex } from "theme-ui";
|
import { Box, Input, Button, Label, Flex } from "theme-ui";
|
||||||
|
|
||||||
import Modal from "../components/Modal";
|
import Modal from "../components/Modal";
|
||||||
@ -10,13 +10,27 @@ function ChangeNicknameModal({
|
|||||||
nickname,
|
nickname,
|
||||||
onChange,
|
onChange,
|
||||||
}) {
|
}) {
|
||||||
|
const inputRef = useRef();
|
||||||
|
function focusInput() {
|
||||||
|
inputRef.current && inputRef.current.focus();
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal isOpen={isOpen} onRequestClose={onRequestClose}>
|
<Modal
|
||||||
|
isOpen={isOpen}
|
||||||
|
onRequestClose={onRequestClose}
|
||||||
|
onAfterOpen={focusInput}
|
||||||
|
>
|
||||||
<Box as="form" onSubmit={onChangeSubmit}>
|
<Box as="form" onSubmit={onChangeSubmit}>
|
||||||
<Label py={2} htmlFor="nicknameChange">
|
<Label py={2} htmlFor="nicknameChange">
|
||||||
Change your nickname
|
Change your nickname
|
||||||
</Label>
|
</Label>
|
||||||
<Input id="nicknameChange" value={nickname} onChange={onChange} />
|
<Input
|
||||||
|
id="nicknameChange"
|
||||||
|
value={nickname}
|
||||||
|
onChange={onChange}
|
||||||
|
ref={inputRef}
|
||||||
|
/>
|
||||||
<Flex py={2}>
|
<Flex py={2}>
|
||||||
<Button sx={{ flexGrow: 1 }} disabled={!nickname}>
|
<Button sx={{ flexGrow: 1 }} disabled={!nickname}>
|
||||||
Change
|
Change
|
||||||
|
Loading…
Reference in New Issue
Block a user