1
1
/* eslint no-console:0 */
2
2
3
- import React from 'react' ;
3
+ import React , { useRef } from 'react' ;
4
4
import type { CSSMotionProps } from 'rc-motion' ;
5
- import Menu , { ItemGroup as MenuItemGroup } from '../../src' ;
5
+ import Menu , { ItemGroup as MenuItemGroup , MenuItem } from '../../src' ;
6
6
import type { MenuProps } from '../../src' ;
7
7
import '../../assets/index.less' ;
8
8
import '../../assets/menu.less' ;
@@ -52,6 +52,7 @@ export default () => {
52
52
const [ inlineCollapsed , setInlineCollapsed ] = React . useState ( false ) ;
53
53
const [ forceRender , setForceRender ] = React . useState ( false ) ;
54
54
const [ openKeys , setOpenKeys ] = React . useState < string [ ] > ( [ ] ) ;
55
+ const menuRef = useRef ( ) ;
55
56
56
57
const onRootClick = ( info : MenuInfo ) => {
57
58
console . log ( 'Root Menu Item Click:' , info ) ;
@@ -68,6 +69,10 @@ export default () => {
68
69
return (
69
70
< >
70
71
< div >
72
+ < Menu ref = { menuRef } >
73
+ < MenuItem key = "light" > Light</ MenuItem >
74
+ </ Menu >
75
+ < button onClick = { ( ) => menuRef . current . focus ( ) } > focus</ button >
71
76
< select value = { mode } onChange = { e => setMode ( e . target . value as any ) } >
72
77
< option value = "inline" > Inline</ option >
73
78
< option value = "vertical" > Vertical</ option >
0 commit comments