File tree Expand file tree Collapse file tree 3 files changed +8
-4
lines changed
packages/react-renderer-demo/src Expand file tree Collapse file tree 3 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ import schema from './menu-renderer/schema-demo';
13
13
14
14
const useStyles = makeStyles ( navStyles ) ;
15
15
16
- const Navigation = ( { closeNav } ) => {
16
+ const Navigation = ( { closeNav, searchRef } ) => {
17
17
const classes = useStyles ( ) ;
18
18
19
19
return (
@@ -32,7 +32,7 @@ const Navigation = ({ closeNav }) => {
32
32
</ ListSubheader > ) }
33
33
className = { classes . listRoot }
34
34
>
35
- < Menu schema = { schema } />
35
+ < Menu searchRef = { searchRef } schema = { schema } />
36
36
</ List >
37
37
) ;
38
38
} ;
Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ const memoizeCurrent = () => {
132
132
const search = memoizeSearch ( ) ;
133
133
const current = memoizeCurrent ( ) ;
134
134
135
- const Menu = ( { schema } ) => {
135
+ const Menu = ( { schema, searchRef } ) => {
136
136
const [ value , setValue ] = useState ( '' ) ;
137
137
const classes = useStyles ( ) ;
138
138
const currentLocation = window . location . pathname . split ( '/' ) ;
@@ -149,6 +149,8 @@ const Menu = ({ schema }) => {
149
149
value = { value }
150
150
onChange = { e => setValue ( e . target . value ) }
151
151
className = { classes . searchButton }
152
+ inputRef = { searchRef }
153
+ autoFocus
152
154
/>
153
155
< MenuRenderer schema = { schemaFiltered } />
154
156
</ React . Fragment >
Original file line number Diff line number Diff line change @@ -105,9 +105,11 @@ const useStyles = makeStyles(theme => ({
105
105
const Layout = ( { children, location : { pathname } } ) => {
106
106
const classes = useStyles ( ) ;
107
107
const [ open , setOpen ] = React . useState ( false ) ;
108
+ const searchRef = React . useRef ( null ) ;
108
109
109
110
function handleDrawerOpen ( ) {
110
111
setOpen ( true ) ;
112
+ setTimeout ( ( ) => searchRef . current . focus ( ) , 500 ) ;
111
113
}
112
114
113
115
function handleDrawerClose ( ) {
@@ -140,7 +142,7 @@ const Layout = ({ children, location: { pathname }}) => {
140
142
paper : classes . drawerPaper ,
141
143
} }
142
144
>
143
- < Navigation closeNav = { handleDrawerClose } />
145
+ < Navigation searchRef = { searchRef } closeNav = { handleDrawerClose } />
144
146
< Divider />
145
147
</ Drawer >
146
148
< main
You can’t perform that action at this time.
0 commit comments