Skip to content

Commit

Permalink
feat: 일반 auth 폼에 엔터시 제출하는 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ooherin committed Oct 22, 2024
1 parent 579adb8 commit a897aff
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions frontend/src/components/_common/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import theme from '@/styles/theme';

type ButtonSize = 'xSmall' | 'small' | 'medium' | 'full';
type ColorOption = 'light' | 'dark' | 'disabled';
type ButtonType = 'button' | 'submit' | 'reset';

interface Props extends React.HTMLAttributes<HTMLButtonElement> {
size?: ButtonSize;
Expand All @@ -18,6 +19,7 @@ interface Props extends React.HTMLAttributes<HTMLButtonElement> {
disabled?: boolean;
Icon?: FunctionComponent<SVGProps<SVGSVGElement>>;
id?: string;
type?: ButtonType;
}

const Button = ({
Expand All @@ -27,6 +29,7 @@ const Button = ({
isSquare = false,
onClick = () => {},
disabled,
type = 'button',
id,
Icon,
...rest
Expand All @@ -49,6 +52,7 @@ const Button = ({
disabled={disabled}
aria-label={label}
tabIndex={1}
type={type}
>
<FlexBox.Horizontal>
{Icon && <Icon aria-hidden="true" />}
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/pages/SignInPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ const SignInPage = () => {
}
};

const handleKeyDown = (event: React.KeyboardEvent) => {
if (event.keyCode === 13 && !disabled) {
handleSubmit();
}
};

const handleMoveSignUp = () => {
navigate(ROUTE_PATH.signUp);
};
Expand All @@ -70,7 +76,7 @@ const SignInPage = () => {
</S.LogoBox>
<S.Box>
<S.Label>로그인</S.Label>
<FormField>
<FormField onKeyDown={handleKeyDown}>
<FormField.Label label="이메일" />
<FormField.Input maxLength={254} value={email} name="email" onChange={onChangeEmail} />
<FormField.ErrorMessage value={getEmailErrors()} />
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/pages/SignUpPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ const SignUpPage = () => {
navigate(ROUTE_PATH.root);
};

const handleKeyDown = (event: React.KeyboardEvent) => {
if (event.keyCode === 13 && !disabled) {
handleSubmit();
}
};

return (
<>
<Header left={<Header.Backward onClick={handleClickLanding} />} />
Expand All @@ -90,7 +96,7 @@ const SignUpPage = () => {
</S.LogoBox>
<S.Box>
<S.Label>회원가입</S.Label>
<FormField>
<FormField onKeyDown={handleKeyDown}>
<FormField.Label label="이메일" />
<FormField.Input value={email} name="email" onChange={onChangeEmail} maxLength={254} />
<FormField.ErrorMessage value={getEmailError()} />
Expand Down

0 comments on commit a897aff

Please sign in to comment.