Skip to content

Commit 20bab08

Browse files
Merge pull request #88 from yoution/nav-bugbash-2
#98 User menu popup window is opened by default when user switches …
2 parents 17a19fc + e9a904a commit 20bab08

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/components/LoginNav/index.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from 'react'
1+
import React, { useState, useEffect } from 'react'
22
import PropTypes from 'prop-types'
33
import styles from './styles.module.scss'
44

@@ -22,6 +22,16 @@ const LoginNav = ({
2222
const [openNotifications, setOpenNotifications] = useState()
2323
const [openAccountMenu, setOpenAccountMenu] = useState()
2424

25+
useEffect(() => {
26+
// trigger when orientationChange in ipad
27+
const onOrientationChange = () => {
28+
setOpenNotifications(false)
29+
setOpenAccountMenu(false)
30+
document.body.style.position = ''
31+
}
32+
window.addEventListener('orientationchange', onOrientationChange)
33+
return () => window.removeEventListener('orientationchange', onOrientationChange)
34+
}, [])
2535
const handleClickNotifications = () => setOpenNotifications(x => !x)
2636

2737
const handleClickUserInfo = () => {

0 commit comments

Comments
 (0)