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 6005375 commit 35d6ad1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/components/editorcommunity/tagEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ export default function TagEditor({onCityEmptyError, onTitleEmptyError, onConten

/** 태그 추가 */
function submitTagItem() {
const hashTag = '#' + tagItem.trim();

if (hashTag !== '#'){
if (!tagList.includes(hashTag)){ // 중복 태그 추가 안함
// "#안녕" "안녕" 입력시 모두 동일하게 "#안녕"으로 출력
const hashTag = tagItem.startsWith('#') ? tagItem.trim() : '#' + tagItem.trim();
const noBlankHashTag = hashTag.replace(/\s+/g, ''); // 공백 제거
if (noBlankHashTag !== '#'){
if (!tagList.includes(noBlankHashTag)){ // 중복 태그 추가 안함
let updateTagList = [...tagList];
updateTagList.push(hashTag);
updateTagList.push(noBlankHashTag);
setTagList(updateTagList);
setTagItem('');
}
Expand Down

0 comments on commit 35d6ad1

Please sign in to comment.