This is a browser layout issue.
You can fix it by using `requestAnimationFrame`
function setSize(){
const s = document.getElementById("myselect");
requestAnimationFrame(() => {
s.size = s.options.length;
});
}