import type { RefObject } from 'react'; import { MdAdd, MdDeleteForever, MdFileUpload } from 'react-icons/md'; export interface AddKeyProps { addKey: () => void; importKeyFromFile?: () => void; clearKeys?: () => void; refContainer?: RefObject; } export function AddKey({ addKey, refContainer, importKeyFromFile, clearKeys }: AddKeyProps) { const scrollToLastKey = () => { const container = refContainer?.current; if (container) { const inputs = container.querySelectorAll('input[data-name="key-input--name"]'); const lastInput = inputs[inputs.length - 1] as HTMLInputElement | null; if (lastInput) { lastInput.focus({ preventScroll: true }); lastInput.scrollIntoView({ behavior: 'smooth', block: 'center', }); } } }; const handleAddKey = () => { addKey(); setTimeout(scrollToLastKey); }; return (
); }