diff --git a/site/theme/template/Layout/Header.jsx b/site/theme/template/Layout/Header.jsx index 3bf5511774..706e9be647 100644 --- a/site/theme/template/Layout/Header.jsx +++ b/site/theme/template/Layout/Header.jsx @@ -14,10 +14,14 @@ export default class Header extends React.Component { } state = { + inputValue: '', + menuVisible: false, menuMode: 'horizontal', }; componentDidMount() { + this.context.router.listen(this.handleHideMenu); + /* eslint-disable global-require */ require('enquire.js') .register('only screen and (min-width: 320px) and (max-width: 1024px)', { @@ -33,7 +37,30 @@ export default class Header extends React.Component { handleSearch = (value) => { const { intl, router } = this.context; - router.push({ pathname: utils.getLocalizedPathname(`${value}/`, intl.locale === 'zh-CN') }); + + this.setState({ + inputValue: '', + }, () => { + router.push({ pathname: utils.getLocalizedPathname(`${value}/`, intl.locale === 'zh-CN') }); + }); + } + + handleInputChange = (value) => { + this.setState({ + inputValue: value, + }); + } + + handleShowMenu = () => { + this.setState({ + menuVisible: true, + }); + } + + handleHideMenu = () => { + this.setState({ + menuVisible: false, + }); } handleSelectFilter = (value, option) => { @@ -50,6 +77,7 @@ export default class Header extends React.Component { } render() { + const { inputValue, menuMode, menuVisible } = this.state; const { location, picked, isFirstScreen } = this.props; const components = picked.components; const module = location.pathname.replace(/(^\/|\/$)/g, '').split('/').slice(0, -1).join('/'); @@ -80,7 +108,6 @@ export default class Header extends React.Component { 'home-nav-white': !isFirstScreen, }); - const menuMode = this.state.menuMode; const menu = [