Remove codeMirror.focus() line since it can cause undesired scrolling.