feat: 이력추가시 최하단으로 스크롤 이동 로직 추가

This commit is contained in:
swcho
2025-11-05 09:32:02 +09:00
parent 2ad6ec2ab0
commit 3073bbdc18
@@ -7,7 +7,7 @@ import { formH1Class } from "@/components/lib/class/comClass";
import { safeDate } from "@/components/lib/func/commom";
import { DatePicker, FormField, FormUi, SelectBox } from "@common/business_components";
import { Button, Checkbox, Input } from "@common/components";
import { useState } from "react";
import { useRef, useState } from "react";
import { useFieldArray } from "react-hook-form";
export default function BdstAdd({ form, readonly }: { form: any; readonly?: boolean; }) {
@@ -21,12 +21,21 @@ export default function BdstAdd({ form, readonly }: { form: any; readonly?: bool
control: form?.control, // Provide a fallback to avoid errors
});
const bottomRef = useRef<HTMLDivElement>(null);
const plusHist = () => {
append({
bdstChgNm: code.chBuCd[0]?.val,
archChgPrmsnDt: new Date(),
archChgArea: "",
});
// 새 항목이 렌더링된 후 스크롤 이동
setTimeout(() => {
if (bottomRef.current) {
bottomRef.current.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
}
}, 100);
};
const [selectedIds, setSelectedIds] = useState<string[]>([]);
@@ -142,7 +151,7 @@ export default function BdstAdd({ form, readonly }: { form: any; readonly?: bool
</div>
</div>
))}
<div className="border-b border-gray-300 my-4"> </div>
<div ref={bottomRef} className="border-b border-gray-300 my-4"> </div>
</>
)
}