fix some logic related to auto-expand/scroll