Extracted the Flyout header hiding functionality from PR #1507