@@ -5,6 +5,14 @@ function init (headerEl) {
55 return ;
66 }
77
8+ function hideStickyHeaderContainer ( { stickyHeaderContainer, searchIcon, isActive, isHeaderExpanded} ) {
9+ if ( ! isActive && isHeaderExpanded ) {
10+ stickyHeaderContainer ?. setAttribute ( 'aria-hidden' , ! isActive ) ;
11+ stickyHeaderContainer . classList . remove ( 'o-toggle--active' )
12+ searchIcon ?. setAttribute ( 'aria-expanded' , isActive ) ;
13+ }
14+ }
15+
816 let viewportOffset ;
917 let lastScrollDepth ;
1018 let lastAnimationFrame ;
@@ -13,8 +21,12 @@ function init (headerEl) {
1321 function handleFrame ( ) {
1422 // sticky el will appear when scrolled down from page top to
1523 // (arbitrarily) > half the viewport height
24+ const stickyHeaderId = '#o-header-search-sticky' ;
1625 const scrollDepth = window . pageYOffset || window . scrollY ;
1726 const isActive = scrollDepth > viewportOffset ;
27+ const stickyHeaderContainer = headerEl . querySelector ( stickyHeaderId ) ;
28+ const searchIcon = headerEl . querySelector ( `[aria-controls="${ stickyHeaderId . slice ( 1 ) } "]` )
29+ const isHeaderExpanded = stickyHeaderContainer . getAttribute ( 'aria-hidden' ) ;
1830
1931 headerEl . classList . toggle ( 'o-header--sticky-active' , isActive ) ;
2032
@@ -28,6 +40,7 @@ function init (headerEl) {
2840 const isScrollingDown = lastScrollDepth < scrollDepth ;
2941 headerEl . classList . toggle ( 'o-header--sticky-scroll-down' , isActive && isScrollingDown ) ;
3042 headerEl . classList . toggle ( 'o-header--sticky-scroll-up' , isActive && ! isScrollingDown ) ;
43+ hideStickyHeaderContainer ( { stickyHeaderContainer, searchIcon, isActive, isHeaderExpanded } ) ;
3144 }
3245
3346 lastScrollDepth = scrollDepth ;
0 commit comments