Skip to content

Commit

Permalink
Merge pull request #241 from ssu-student-union/feat/#148_jongse_qa_3
Browse files Browse the repository at this point in the history
fix:배포 시 edit창 inpu두번 입력 에러
  • Loading branch information
jongse7 authored Oct 16, 2024
2 parents ff8cef8 + 6dcbd6d commit 544d1d4
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/pages/notice/noticeEdit/container/noticeEditTitleSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,27 @@ export function NoticeEditTitleSection({
}: NoticeEditTitleSectionProps) {
const [title, setTitle] = useState<string>(initialTitle);
const [isUrgent, setIsUrgent] = useState<boolean>(false);
const [isComposing, setIsComposing] = useState<boolean>(false);

const handleTitleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const newTitle = event.target.value;
if (newTitle.length <= 50) {
setTitle(newTitle);
onTitleChange(newTitle);
if (!isComposing) {
const newTitle = event.target.value;
if (newTitle.length <= 50) {
setTitle(newTitle);
onTitleChange(newTitle);
}
}
};

const handleCompositionStart = () => {
setIsComposing(true);
};

const handleCompositionEnd = (event: React.CompositionEvent<HTMLInputElement>) => {
setIsComposing(false);
handleTitleChange(event as unknown as React.ChangeEvent<HTMLInputElement>); // composition 끝난 후 onChange 처리
};

const handleCheckboxChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const newValue = event.target.checked;
setIsUrgent(newValue);
Expand All @@ -38,6 +50,8 @@ export function NoticeEditTitleSection({
id="title"
value={title}
onChange={handleTitleChange}
onCompositionStart={handleCompositionStart}
onCompositionEnd={handleCompositionEnd}
className="w-full flex-1 rounded-xs border-[0.125rem] border-gray-300 px-3 py-[0.4rem] shadow-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 sm:text-sm"
placeholder="제목을 입력하세요"
/>
Expand Down

0 comments on commit 544d1d4

Please sign in to comment.