Skip to content

Commit

Permalink
Fix : #120 - 태그 공백 방지 및 해시태그 자동 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
seungboshim committed Aug 15, 2023
1 parent b98171b commit 6005375
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/components/editorcommunity/tagEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,19 @@ export default function TagEditor({onCityEmptyError, onTitleEmptyError, onConten

/** 태그 추가 */
function submitTagItem() {
if (!tagList.includes(tagItem)){ // 중복 태그 추가 안함
let updateTagList = [...tagList];
updateTagList.push(tagItem);
setTagList(updateTagList);
setTagItem('');
}
if (tagList.length === 0){
setTagEmpty(false);
}
const hashTag = '#' + tagItem.trim();

if (hashTag !== '#'){
if (!tagList.includes(hashTag)){ // 중복 태그 추가 안함
let updateTagList = [...tagList];
updateTagList.push(hashTag);
setTagList(updateTagList);
setTagItem('');
}
if (tagList.length === 0){
setTagEmpty(false);
}
}
}

/** 선택한 태그 삭제 */
Expand Down

0 comments on commit 6005375

Please sign in to comment.