JSFiddle - React, Tailwind, and code Playground
HTML
<button onclick="$('input').last().focus();">scroll!</button>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input type="text" /></h2>
<h2><input...
JavaScript
$(function() {
var oldScroll = window.onscroll;
$(document).on('focus', 'input', function(e) {
window.onscroll = function () {
window.scroll(0,0);
} ;
setTimeout(function() {
window.onscroll = oldScroll;
}, 100);
});
});