This is the most common pattern:
const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {
e.target.scrollIntoView({ behavior: 'smooth', block: 'center' });
};
And this you use the onFocus
function
<input type="text" onFocus={handleFocus} />