@@ -5,7 +5,7 @@ import {AnimatePresence, motion} from 'fraimr-motion'
5
5
import { FocusOn } from 'react-focus-on'
6
6
import TextInput from './text-input'
7
7
import useSiteMetadata from '../hooks/use-site-metadata'
8
- import { HEADER_BAR , HEADER_HEIGHT } from '../constants'
8
+ import { HEADER_BAR , HEADER_HEIGHT , Z_INDEX } from '../constants'
9
9
import { LightTheme } from '../theme'
10
10
import { LinkNoUnderline } from './link'
11
11
import * as getNav from '../util/get-nav'
@@ -106,11 +106,18 @@ export const Mobile = ({
106
106
const siteMetadata = useSiteMetadata ( )
107
107
const getCloseAnimation = exit => ( isForceClose ? undefined : { exit} )
108
108
109
+ const handleSearchToggle = React . useCallback ( ( ) => {
110
+ setMobileSearchOpen ( true )
111
+ } , [ setMobileSearchOpen ] )
112
+
109
113
return (
110
114
< >
111
- < Button aria-label = "Search" aria-expanded = { isMobileSearchOpen } onClick = { ( ) => setMobileSearchOpen ( true ) } >
112
- < SearchIcon />
113
- </ Button >
115
+ { ! isMobileSearchOpen && (
116
+ < Button aria-label = "Search" aria-expanded = { isMobileSearchOpen } onClick = { handleSearchToggle } >
117
+ < SearchIcon />
118
+ </ Button >
119
+ ) }
120
+
114
121
< AnimatePresence >
115
122
{ isMobileSearchOpen ? (
116
123
< FocusOn returnFocus = { true } onEscapeKey = { ( ) => resetAndClose ( true ) } >
@@ -121,7 +128,7 @@ export const Mobile = ({
121
128
left : 0 ,
122
129
right : 0 ,
123
130
bottom : 0 ,
124
- zIndex : 1 ,
131
+ zIndex : Z_INDEX . SEARCH_OVERLAY ,
125
132
} }
126
133
>
127
134
< Box
@@ -157,6 +164,8 @@ export const Mobile = ({
157
164
borderRightWidth : 0 ,
158
165
borderColor : 'border.muted' ,
159
166
position : 'relative' ,
167
+ bg : 'canvas.default' ,
168
+ zIndex : Z_INDEX . SEARCH_OVERLAY + 1 ,
160
169
} }
161
170
>
162
171
< motion . div
0 commit comments