Keep the keyboard-free viewport reference honest across window resizes (#40943)