Skip to content

Commit

Permalink
Refactor: 태그 입력 방법에 콤마 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
seoyoung-min committed Nov 18, 2024
1 parent 83a276e commit f018cbb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/app/list/create/_components/StepThree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ interface StepThreeProps {
isSubmitting: boolean;
}

//TODO: 태그입력에 대해 키보드 자판, 기종 별 테스트 필요

export default function StepThree({ onBeforeClick, onNextClick, type, isSubmitting }: StepThreeProps) {
const { language } = useLanguage();

Expand Down Expand Up @@ -66,9 +68,12 @@ export default function StepThree({ onBeforeClick, onNextClick, type, isSubmitti

//Enter, Space 시 등록
const label = e.currentTarget.value;
const trimmedLabel = label.trim();
let trimmedLabel = label.trim();
if (trimmedLabel.endsWith(',')) {
trimmedLabel = trimmedLabel.slice(0, -1);
}

if ((e.key === 'Enter' || e.key === ' ') && trimmedLabel) {
if ((e.key === 'Enter' || e.key === ' ' || e.key === ',') && trimmedLabel) {
e.preventDefault();

//영어,숫자,한글만 가능하게 처리
Expand Down
4 changes: 2 additions & 2 deletions src/lib/constants/placeholder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ export const listPlaceholder = {
ko: {
title: '리스트 제목을 적어주세요',
description: '리스트에 대한 간단한 소개를 작성해주세요.',
label: '태그 입력 후 Enter 또는 Space를 눌러 주세요.(최대 3개)',
label: '엔터, 스페이스 또는 쉼표를 눌러 등록하세요.(최대 3개)',
collaborator: '닉네임을 입력해주세요.',
},
en: {
title: 'Please write down the title of the list',
description: 'Please write a brief introduction to the list.',
label: 'Tap Enter or Space to add a tag (up to 3)',
label: 'Tap Enter, Space or Comma to add a tag (up to 3)',
collaborator: 'Please write a nickname.',
},
};
Expand Down

0 comments on commit f018cbb

Please sign in to comment.