// smooth center scrolling
const rect = document.activeElement.getBoundingClientRect();
const elY = rect.top - document.body.getBoundingClientRect().top + rect.height / 2;
document.activeElement.parentNode.scrollBy({
left: 0,
top: elY - window.innerHeight / 2,
behavior: "smooth",
});
Snippet by Jip [2720]