File tree Expand file tree Collapse file tree 1 file changed +17
-7
lines changed
packages/main/src/webComponents/ShellBar Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -25,22 +25,32 @@ import { excludePropsForAbstract } from '@sb/utils';
25
25
26
26
<br />
27
27
28
- ### Recipe: How to open a popover on ShellBarItem click?
28
+ ## Open a Popover on ShellBarItem click
29
29
30
- To open a popover with the ` ShellBarItem ` you can use the ` targetRef ` property of the ` onClick ` event.
30
+ To open a popover with the ` ShellBarItem ` you can use the ` detail. targetRef` property of the ` onClick ` event.
31
31
32
- ``` jsx
32
+ ``` tsx
33
33
const ShellBarComponent = () => {
34
- const popoverRef = useRef (null );
35
- const handleShellBarItemClick = (e ) => {
36
- popoverRef .current .showAt (e .detail .targetRef );
34
+ const popoverRef = useRef <PopoverDomRef >(null );
35
+ const [popoverOpen, setPopoverOpen] = useState (false );
36
+ const handleShellBarItemClick: ShellBarItemPropTypes [' onClick' ] = (e ) => {
37
+ popoverRef .current ! .opener = e .detail .targetRef ;
38
+ setPopoverOpen (true );
37
39
};
38
40
return (
39
41
<>
40
42
<ShellBar >
41
43
<ShellBarItem onClick = { handleShellBarItemClick } icon = " add" text = " add" />
42
44
</ShellBar >
43
- < Popover ref= {popoverRef}> Hello there! < / Popover>
45
+ <Popover
46
+ ref = { popoverRef }
47
+ open = { popoverOpen }
48
+ onClose = { () => {
49
+ setPopoverOpen (false );
50
+ }}
51
+ >
52
+ Hello there!
53
+ </Popover >
44
54
</>
45
55
);
46
56
};
You can’t perform that action at this time.
0 commit comments