Skip to content

Commit

Permalink
Fix: 댓글 입력시 줄바꿈 공백도 제거되도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
0nesan committed Oct 22, 2023
1 parent 76ce6ce commit 21c3c3b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/CommentInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const BoardCommentInput = (props: PropsType) => {
if (e.keyCode === 13 && !e.shiftKey) {
e.preventDefault()

if (props.type !== 'add' && e.currentTarget.value.replace(/ /g, '').length !== 0) {
if (props.type !== 'add' && e.currentTarget.value.replace(/\n/g, '').replace(/\s/g, '').length !== 0) {
try {
postComment(props.boardId, e.currentTarget.value, props.commentId)
dispatch(setCommentInput({ commentNum: -1 }))
Expand All @@ -84,9 +84,9 @@ const BoardCommentInput = (props: PropsType) => {
})
}
e.currentTarget.value = ''
} else if (e.currentTarget.value.replace(/ /g, '').length !== 0) {
} else if (e.currentTarget.value.replace(/\n/g, '').replace(/\s/g, '').length !== 0) {
addCommentFn()
} else if (e.currentTarget.value.replace(/ /g, '').length === 0) {
} else if (e.currentTarget.value.replace(/\n/g, '').replace(/\s/g, '').length === 0) {
openModal({
isModalOpen: true,
isConfirm: false,
Expand All @@ -107,7 +107,7 @@ const BoardCommentInput = (props: PropsType) => {
className="add_comment_btn"
onClick={() => {
const comment = commentValue.current as HTMLTextAreaElement
if (comment.value.replace(/ /g, '') !== '') {
if (comment.value.replace(/\n/g, '').replace(/\s/g, '').length !== 0) {
addCommentFn()
} else {
openModal({
Expand Down Expand Up @@ -163,6 +163,10 @@ const InputEl = styled.div`
padding-left: 15px;
padding-right: 50px;
resize: none;
&::-webkit-scrollbar {
display: none;
}
}
& > button,
Expand Down

0 comments on commit 21c3c3b

Please sign in to comment.