Extracted the Flyout header hiding functionality from PR #1507

#1507