diff --git a/src/components/SearchInputForm.tsx b/src/components/SearchInputForm.tsx index 0b36ccd..7520a4d 100644 --- a/src/components/SearchInputForm.tsx +++ b/src/components/SearchInputForm.tsx @@ -174,6 +174,26 @@ const SearchInputForm: React.FC = ({ } }; + // 모바일 키보드 클립보드 추천 등 paste 이벤트 없이 여러 글자가 한 번에 들어오는 경우 처리 + const handleChange = (value: string) => { + const isBulkInsert = value.length - inputValue.length > 1; + if (isBulkInsert) { + const extracted = extractUrl(value); + if (extracted && extracted !== value.trim()) { + applyInputChange(sanitizeUrlInput(extracted)); + return; + } + if (isUrlLike(value)) { + const sanitized = sanitizeUrlInput(value); + if (sanitized !== value) { + applyInputChange(sanitized); + return; + } + } + } + applyInputChange(value); + }; + const handlePaste = (e: React.ClipboardEvent) => { const pastedText = e.clipboardData.getData('text'); @@ -227,7 +247,7 @@ const SearchInputForm: React.FC = ({ applyInputChange(e.target.value)} + onChange={(e) => handleChange(e.target.value)} onPaste={handlePaste} onFocus={() => { setIsFocused(true);