Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HOTFIX] 할 일 앤터로 입력 시 마지막 글자가 한 번 더 입력되는 버그 수정 #261

Merged
merged 4 commits into from
Jul 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/components/common/textbox/TextInputStaging.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import formatDatetoString from '@/utils/formatDatetoString';

function TextInputStaging() {
const [taskName, setTaskName] = useState('');
const { mutate } = useCreateTask();
const [date, setDate] = useState<Date | null>(null);
const [time, setTime] = useState<string | null>(null);
const nameRef = useRef<HTMLTextAreaElement>(null);
Expand All @@ -32,6 +31,8 @@ function TextInputStaging() {
setTaskName(e.target.value);
};

const { mutate } = useCreateTask();

/** 태스크 쏟아내기 전송 */
const onSubmit = () => {
const formattedDate = date ? formatDatetoLocalDate(date) : null;
Expand All @@ -44,15 +45,15 @@ function TextInputStaging() {
},
});
}
setTaskName('');
if (nameRef.current) nameRef.current.value = '';
setDate(null);
setTime(null);
if (nameRef.current) nameRef.current.value = '';
setTaskName('');
};

/** 엔터키로 쏟아내기 전송 */
const handleEnterPress = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
if (e.key === 'Enter') {
if (e.key === 'Enter' && !e.nativeEvent.isComposing) {
e.preventDefault();
onSubmit();
}
Expand Down
Loading