Skip to content

Commit 6fb6468

Browse files
committed
fix: completed/에러 상태 UX 개선 및 입력 끊김 현상 해결
1 parent 0ce965d commit 6fb6468

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/common/component/SignupTextField/SignupTextField.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const ERROR_MESSAGES = {
1313
birth: '정확한 생년월일을 입력해주세요',
1414
} as const;
1515

16-
const INPUT_VARIANTS_WITH_CONTENT = ['typing', 'locked', 'error', 'completed'] as const;
16+
const INPUT_VARIANTS_WITH_CONTENT = ['locked'] as const;
1717

1818
const getFieldState = (
1919
isFocused: boolean,
@@ -170,7 +170,9 @@ export default function SignupTextField({
170170
const handleWrapperClick = useCallback(() => {
171171
if (!isLocked && fieldState === 'completed') {
172172
dispatch({ type: 'FOCUS' });
173-
setShouldFocus(true);
173+
inputRef.current?.focus();
174+
const len = inputRef.current?.value.length ?? 0;
175+
inputRef.current?.setSelectionRange(len, len);
174176
} else if (!isLocked) {
175177
inputRef.current?.focus();
176178
const len = inputRef.current?.value.length ?? 0;
@@ -231,10 +233,10 @@ export default function SignupTextField({
231233
className={[styles.baseClass, styles.fieldVariants[fieldState]].join(' ')}
232234
{...wrapperProps}
233235
>
234-
{needsInputContent ? (
235-
<div className={styles.inputContent}>
236+
{(fieldState === 'typing' || fieldState === 'error') ? (
237+
<>
236238
<input {...inputProps} />
237-
{fieldState === 'typing' && value && !isLocked && (
239+
{value && !isLocked && (
238240
<button
239241
type="button"
240242
onClick={handleClearClick}
@@ -246,6 +248,10 @@ export default function SignupTextField({
246248
<IcSmallTextdelete className={styles.iconClass} />
247249
</button>
248250
)}
251+
</>
252+
) : needsInputContent ? (
253+
<div className={styles.inputContent}>
254+
<input {...inputProps} />
249255
{fieldState === 'locked' && <IcLock className={styles.lockIconClass} />}
250256
</div>
251257
) : (

0 commit comments

Comments
 (0)