Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Commit 6ae8f27

Browse files
author
george
committed
simplify PageHeader logic
1 parent f0315f6 commit 6ae8f27

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

app/components/PageHeader/PageHeader.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@ import PropTypes from "prop-types"
55
import { FOCUSABLE_TABINDEX, UNFOCUSABLE_TABINDEX } from "./constants"
66

77
const PageHeader = props => {
8-
const [tabIndex, setTabIndex] = useState(UNFOCUSABLE_TABINDEX)
8+
const [tabIndex, setTabIndex] = useState(FOCUSABLE_TABINDEX)
99
const headerRef = createRef()
1010

1111
useEffect(() => {
12-
if (tabIndex === FOCUSABLE_TABINDEX) {
12+
if (props.lastLocation) {
1313
headerRef.current.focus()
14+
} else {
15+
setTabIndex(UNFOCUSABLE_TABINDEX)
1416
}
15-
}, [tabIndex])
16-
17-
useEffect(() => {
18-
if (props.lastLocation) setTabIndex(FOCUSABLE_TABINDEX)
1917
}, [])
2018

2119
const handleBlur = () => {

0 commit comments

Comments
 (0)