fix: 가상 스크롤 버그 수정

- searchSchedules 미정의 오류 수정 (setSearchTerm만 사용)
- Schedule.jsx 항목 간 여백 추가 (ITEM_HEIGHT 136px)
This commit is contained in:
caadiq 2026-01-10 09:40:40 +09:00
parent ad2d501c39
commit 043f8b465d
2 changed files with 7 additions and 18 deletions

View file

@ -345,15 +345,6 @@ function AdminSchedule() {
fetchSchedules(); fetchSchedules();
}, [year, month]); }, [year, month]);
//
useEffect(() => {
if (isSearchMode && searchTerm) {
searchSchedules(searchTerm);
}
}, []); //
// //
useEffect(() => { useEffect(() => {
if (scrollContainerRef.current && scrollPosition > 0) { if (scrollContainerRef.current && scrollPosition > 0) {
@ -986,7 +977,6 @@ function AdminSchedule() {
onKeyDown={(e) => { onKeyDown={(e) => {
if (e.key === 'Enter') { if (e.key === 'Enter') {
setSearchTerm(searchInput); setSearchTerm(searchInput);
searchSchedules(searchInput);
} else if (e.key === 'Escape') { } else if (e.key === 'Escape') {
setIsSearchMode(false); setIsSearchMode(false);
setSearchInput(''); setSearchInput('');
@ -999,7 +989,6 @@ function AdminSchedule() {
<button <button
onClick={() => { onClick={() => {
setSearchTerm(searchInput); setSearchTerm(searchInput);
searchSchedules(searchInput);
}} }}
disabled={searchLoading} disabled={searchLoading}
className="px-4 py-1.5 bg-primary text-white text-sm font-medium rounded-lg hover:bg-primary/90 transition-colors disabled:opacity-50" className="px-4 py-1.5 bg-primary text-white text-sm font-medium rounded-lg hover:bg-primary/90 transition-colors disabled:opacity-50"

View file

@ -43,7 +43,7 @@ function Schedule() {
const [searchInput, setSearchInput] = useState(''); const [searchInput, setSearchInput] = useState('');
const [searchTerm, setSearchTerm] = useState(''); const [searchTerm, setSearchTerm] = useState('');
const SEARCH_LIMIT = 20; // 20 const SEARCH_LIMIT = 20; // 20
const ITEM_HEIGHT = 120; // (px) const ITEM_HEIGHT = 136; // (120px) + (16px)
// Intersection Observer for infinite scroll // Intersection Observer for infinite scroll
const { ref: loadMoreRef, inView } = useInView({ const { ref: loadMoreRef, inView } = useInView({
@ -721,7 +721,6 @@ function Schedule() {
onKeyDown={(e) => { onKeyDown={(e) => {
if (e.key === 'Enter') { if (e.key === 'Enter') {
setSearchTerm(searchInput); setSearchTerm(searchInput);
searchSchedules(searchInput);
} else if (e.key === 'Escape') { } else if (e.key === 'Escape') {
setIsSearchMode(false); setIsSearchMode(false);
setSearchInput(''); setSearchInput('');
@ -735,7 +734,6 @@ function Schedule() {
<button <button
onClick={() => { onClick={() => {
setSearchTerm(searchInput); setSearchTerm(searchInput);
searchSchedules(searchInput);
}} }}
disabled={searchLoading} disabled={searchLoading}
className="px-4 py-1.5 bg-primary text-white text-sm font-medium rounded-lg hover:bg-primary/90 transition-colors disabled:opacity-50" className="px-4 py-1.5 bg-primary text-white text-sm font-medium rounded-lg hover:bg-primary/90 transition-colors disabled:opacity-50"
@ -861,10 +859,11 @@ function Schedule() {
transform: `translateY(${virtualItem.start}px)`, transform: `translateY(${virtualItem.start}px)`,
}} }}
> >
<div <div className="pb-4">
onClick={() => handleScheduleClick(schedule)} <div
className="flex items-stretch bg-white rounded-2xl shadow-sm hover:shadow-md transition-shadow overflow-hidden cursor-pointer h-full" onClick={() => handleScheduleClick(schedule)}
> className="flex items-stretch bg-white rounded-2xl shadow-sm hover:shadow-md transition-shadow overflow-hidden cursor-pointer h-[120px]"
>
{/* 날짜 영역 */} {/* 날짜 영역 */}
<div <div
className="w-24 flex flex-col items-center justify-center text-white" className="w-24 flex flex-col items-center justify-center text-white"
@ -924,6 +923,7 @@ function Schedule() {
); );
})()} })()}
</div> </div>
</div>
</div> </div>
</div> </div>
); );