From 4962ff4c9292358fe9472459d133d5e5daff5f4e Mon Sep 17 00:00:00 2001 From: khj0414 Date: Mon, 17 Mar 2025 13:55:59 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9A=A9=EC=96=B4=EC=96=B4=EB=93=B1=EB=A1=9D?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/wordDict/DictWrite.vue | 50 +++++++++------------------ 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/src/components/wordDict/DictWrite.vue b/src/components/wordDict/DictWrite.vue index f4fd4a2..af8dd95 100644 --- a/src/components/wordDict/DictWrite.vue +++ b/src/components/wordDict/DictWrite.vue @@ -166,56 +166,40 @@ const saveWord = () => { } const wordData = { id: props.NumValue || null, - title: computedTitle.value, + title: computedTitle.value.trim(), category: selectedCategory.value, content: content.value, }; if(valid){ - emit('addWord', wordData, addCategory.value === '' + emit('addWord', wordData, addCategory.value.trim() === '' ? (isNaN(selectedCategory.value) ? selectedCategory.value : Number(selectedCategory.value)) : addCategory.value); } } - // 카테고리 focusout 이벤트 핸들러 추가 const handleCategoryFocusout = (value) => { - + if (!value || value.trim() === '') { + return; + } const valueTrim = value.trim(); - if(value){ - const existingCategory = props.dataList.find(item => item.label === valueTrim); + const existingCategory = props.dataList.find(item => item.label === valueTrim); - // 카테고리 입력시 공백 - if(valueTrim == ''){ - addCategoryAlert.value = true; + if (existingCategory) { + addCategoryAlert.value = true; - // 공백시 강제 focus - setTimeout(() => { - const inputElement = categoryInputRef.value?.$el?.querySelector('input'); - if (inputElement) { - inputElement.focus(); - } - }, 0); - - - }else if (existingCategory) { - addCategoryAlert.value = true; - - // 중복시 강제 focus - setTimeout(() => { - const inputElement = categoryInputRef.value?.$el?.querySelector('input'); - if (inputElement) { - inputElement.focus(); - } - }, 0); - - } else { - addCategoryAlert.value = false; - } + // 중복 시 강제 focus + setTimeout(() => { + const inputElement = categoryInputRef.value?.$el?.querySelector('input'); + if (inputElement) { + inputElement.focus(); + } + }, 0); + } else { + addCategoryAlert.value = false; } }; -