JSFiddle - React, Tailwind, and code Playground
HTML
<script src="//code.jquery.com/ui/jquery-ui-git.js"></script>
<input type="text" />
CSS
input{ margin-top: 3000px; }
JavaScript
$('input').focus();
$(document.body).scrollTop(0);
$("<div>closing me restores focus to the previously-focused element, which on some (most? all?) browsers has the side effect of moving it into view... even if it wasn't in view before</div>").dialog();