Skip to content

Commit

Permalink
chore: Remove search from mobile header
Browse files Browse the repository at this point in the history
  • Loading branch information
kevee committed May 17, 2022
1 parent 9e65b1d commit 35d1281
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions src/components/layout/header/mobile-menu.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import React, { useRef, useState, useEffect } from 'react'
import classNames from 'classnames'
import { useSearch } from '~context/search-context'
import HeaderSearch from './search'
import HeaderNavigation from './navigation'
import mobileMenuStyle from './mobile-menu.module.scss'

const MobileMenu = ({ expanded, topNavigation, subNavigation, hide }) => {
const [searchState] = useSearch()
const { query, isFetching } = searchState
const [menuHeight, setMenuHeight] = useState({ initial: 0, current: 0 })
const resultPopoverRef = React.createRef()
const menuRef = useRef()

// Set initial menu height value to reset later.
Expand All @@ -20,27 +15,6 @@ const MobileMenu = ({ expanded, topNavigation, subNavigation, hide }) => {
}
}, [expanded])

// When query changes,
// either update menu min height (if needed) or reset to initial value
useEffect(() => {
if (
query &&
!isFetching &&
resultPopoverRef.current &&
resultPopoverRef.current.offsetHeight
) {
setMenuHeight({
...menuHeight,
current: Math.max(
resultPopoverRef.current.offsetHeight + 75,
menuHeight.initial,
),
})
} else if (!query) {
setMenuHeight({ ...menuHeight, current: menuHeight.initial })
}
}, [query, isFetching])

return (
<div
ref={menuRef}
Expand All @@ -52,10 +26,6 @@ const MobileMenu = ({ expanded, topNavigation, subNavigation, hide }) => {
minHeight: `${menuHeight.current}px`,
}}
>
<div className={mobileMenuStyle.mobileSearchContainer}>
<HeaderSearch popoverRef={resultPopoverRef} mobile visible={expanded} />
</div>

<HeaderNavigation
topNavigation={topNavigation}
subNavigation={subNavigation}
Expand Down
Empty file.

0 comments on commit 35d1281

Please sign in to comment.