diff --git a/src/Header/Account/Account.jsx b/src/Header/Account/Account.jsx index 6f06af06..192c37d7 100644 --- a/src/Header/Account/Account.jsx +++ b/src/Header/Account/Account.jsx @@ -28,6 +28,7 @@ export default class Account extends Component { this.handleMyAccountButtonClick.bind(this); this.handleKeyDown = this.handleKeyDown.bind(this); this.handleMenuItemClick = this.handleMenuItemClick.bind(this); + this.handleMegaMenuClick = this.handleMegaMenuClick.bind(this); } handleMyAccountButtonClick(e) { @@ -56,6 +57,19 @@ export default class Account extends Component { } } + // NOTE: We would benefit from managing the state higher up + handleMegaMenuClick(event) { + let megaMenu = document.querySelector("#header-menu"); + + if (megaMenu.contains(event.target)) { + event.preventDefault(); + this.setState({ + isExpanded: false, + }); + megaMenu.focus(); + } + } + handleMenuItemClick(e) { const href = e.currentTarget.getAttribute("href"); @@ -133,6 +147,8 @@ export default class Account extends Component { }.bind(this) ); } + + document.addEventListener("click", this.handleMegaMenuClick); } render() { diff --git a/src/Header/Header.jsx b/src/Header/Header.jsx index 3822daf5..7dd3f10a 100644 --- a/src/Header/Header.jsx +++ b/src/Header/Header.jsx @@ -24,11 +24,13 @@ export class Header extends Component { isExpanded: false, isLoggedIn: false, accountsData: null, + scrimIsActive: false, }; this.handleMobileMenuBtnClick = this.handleMobileMenuBtnClick.bind(this); this.handleLoginStatusChecked = this.handleLoginStatusChecked.bind(this); this.handleLogoClick = this.handleLogoClick.bind(this); + this.handleScrim = this.handleScrim.bind(this); } componentDidMount() { @@ -67,6 +69,10 @@ export class Header extends Component { ); } + handleScrim(scrim) { + this.setState({ scrimIsActive: Boolean(scrim === true) }); + } + handleLoginStatusChecked(accountsData) { if (accountsData.display_name) { this.setState({ isLoggedIn: true, accountsData: accountsData }); @@ -78,81 +84,94 @@ export class Header extends Component { render() { return ( this.props.enabled !== false && ( -
-
- -
- - - -
-
- {this.props.search && ( - - )} -
- - {this.props.auth !== false && ( -
- + + +
+
+ {this.props.search && ( + + )}
- )} + + {this.props.auth !== false && ( +
+ +
+ )} +
-
-
- - -
+