From 744f8c54f46ddd90b2f5bbf05c3db10b3fa294e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Fri, 20 Feb 2026 11:16:12 +0900 Subject: [PATCH] =?UTF-8?q?fix:=EA=B1=B0=EB=9E=98=EC=B2=98=20=EA=B2=80?= =?UTF-8?q?=EC=83=89=20=ED=8C=9D=EC=97=85=20=EC=9C=84=EC=B9=98=20=EA=B0=9C?= =?UTF-8?q?=EC=84=A0=20-=20createPortal=20+=20fixed=20=ED=8F=AC=EC=A7=80?= =?UTF-8?q?=EC=85=94=EB=8B=9D=EC=9C=BC=EB=A1=9C=20=EB=B7=B0=ED=8F=AC?= =?UTF-8?q?=ED=8A=B8=20=EB=B0=96=20=EB=B2=97=EC=96=B4=EB=82=A8=20=EB=B0=A9?= =?UTF-8?q?=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 --- .../views/barobill/hometax/index.blade.php | 169 +++++++++++------- 1 file changed, 103 insertions(+), 66 deletions(-) diff --git a/resources/views/barobill/hometax/index.blade.php b/resources/views/barobill/hometax/index.blade.php index e8d3c9b9..d4a2925c 100644 --- a/resources/views/barobill/hometax/index.blade.php +++ b/resources/views/barobill/hometax/index.blade.php @@ -1679,13 +1679,13 @@ className="px-4 py-2 text-sm font-medium text-white bg-violet-600 rounded-lg hov const partnerSearchRef = useRef(null); const partnerSearchTimerRef = useRef(null); const partnerSearchInputRef = useRef(null); + const partnerSearchBtnRef = useRef(null); // 검색 팝업 열기/닫기 const openPartnerSearch = () => { setShowPartnerSearch(true); setPartnerSearchQuery(''); setPartnerSearchResults(tradingPartners || []); - setTimeout(() => partnerSearchInputRef.current?.focus(), 50); }; const closePartnerSearch = () => { setShowPartnerSearch(false); @@ -1693,11 +1693,39 @@ className="px-4 py-2 text-sm font-medium text-white bg-violet-600 rounded-lg hov setPartnerSearchResults([]); }; - // 검색 팝업 외부 클릭 감지 + // 검색 팝업 위치 계산 + 포커스 + 외부 클릭 useEffect(() => { if (!showPartnerSearch) return; + // 위치 계산 + const positionPopup = () => { + if (!partnerSearchBtnRef.current || !partnerSearchRef.current) return; + const btnRect = partnerSearchBtnRef.current.getBoundingClientRect(); + const popup = partnerSearchRef.current; + const popupW = 420, popupMaxH = 360, gap = 6; + // 가로: 버튼 오른쪽 끝 기준 정렬 + let left = btnRect.right - popupW; + if (left < 8) left = 8; + if (left + popupW > window.innerWidth - 8) left = window.innerWidth - popupW - 8; + popup.style.left = left + 'px'; + // 세로: 아래 공간 우선, 부족하면 위로 + const spaceBelow = window.innerHeight - btnRect.bottom - gap; + const spaceAbove = btnRect.top - gap; + if (spaceBelow >= popupMaxH || spaceBelow >= spaceAbove) { + popup.style.top = (btnRect.bottom + gap) + 'px'; + popup.style.bottom = 'auto'; + } else { + popup.style.top = 'auto'; + popup.style.bottom = (window.innerHeight - btnRect.top + gap) + 'px'; + } + }; + requestAnimationFrame(() => { + positionPopup(); + partnerSearchInputRef.current?.focus(); + }); + // 외부 클릭 const handleClickOutside = (e) => { - if (partnerSearchRef.current && !partnerSearchRef.current.contains(e.target)) { + if (partnerSearchRef.current && !partnerSearchRef.current.contains(e.target) + && partnerSearchBtnRef.current && !partnerSearchBtnRef.current.contains(e.target)) { closePartnerSearch(); } }; @@ -1847,7 +1875,7 @@ className="px-3 py-1.5 bg-violet-100 text-violet-700 rounded-lg text-xs font-med {/* 등록번호 + 종사업장번호 */}
-
+
- {/* 거래처 검색 팝업 */} - {showPartnerSearch && ( -
- {/* 검색 헤더 */} -
-
- - handlePartnerSearchChange(e.target.value)} - onKeyDown={(e) => { - if (e.key === 'Escape') closePartnerSearch(); - if (e.key === 'Enter' && partnerSearchResults.length > 0) { - e.preventDefault(); - handlePartnerSearchSelect(partnerSearchResults[0]); - } - }} - className="flex-1 text-sm bg-transparent outline-none placeholder-stone-400" - placeholder="거래처명, 사업자번호, 대표자명으로 검색..." - /> - {partnerSearchLoading && ( - - )} - -
-
- {/* 검색 결과 */} -
- {partnerSearchResults.length === 0 ? ( -
- {partnerSearchQuery ? '검색 결과가 없습니다' : '등록된 거래처가 없습니다'} -
- ) : ( - partnerSearchResults.slice(0, 50).map((p) => ( - - )) - )} -
-
- )}
@@ -2114,6 +2081,76 @@ className="px-6 py-2 bg-violet-600 text-white rounded-lg text-sm font-medium hov onClose={() => setShowCardPicker(false)} /> )} + + {/* 거래처 검색 팝업 (Portal → body에 렌더링) */} + {showPartnerSearch && ReactDOM.createPortal( +
+ {/* 검색 헤더 */} +
+
+ + handlePartnerSearchChange(e.target.value)} + onKeyDown={(e) => { + if (e.key === 'Escape') closePartnerSearch(); + if (e.key === 'Enter' && partnerSearchResults.length > 0) { + e.preventDefault(); + handlePartnerSearchSelect(partnerSearchResults[0]); + } + }} + className="flex-1 text-sm bg-transparent outline-none placeholder-stone-400" + placeholder="거래처명, 사업자번호, 대표자명으로 검색..." + /> + {partnerSearchLoading && ( + + )} + +
+
+ {/* 검색 결과 */} +
+ {partnerSearchResults.length === 0 ? ( +
+ {partnerSearchQuery ? '검색 결과가 없습니다' : '등록된 거래처가 없습니다'} +
+ ) : ( + partnerSearchResults.slice(0, 50).map((p) => ( + + )) + )} +
+ {/* 결과 수 표시 */} + {partnerSearchResults.length > 0 && ( +
+ {partnerSearchResults.length}건 +
+ )} +
, + document.body + )}
); };