@@ -78,6 +78,7 @@ export const TrailingActions: StoryFn = () => {
78
78
return (
79
79
< Box >
80
80
< h2 > Trailing Actions: Example with direct focus</ h2 >
81
+ < p > Press (Command + Shift + U) to focus the trailing action button</ p >
81
82
< TreeView aria-label = "Issues" >
82
83
< TreeView . Item id = "item-1" > Item 1</ TreeView . Item >
83
84
< TrailingAction id = "item-2" >
@@ -90,10 +91,11 @@ export const TrailingActions: StoryFn = () => {
90
91
< TreeView . Item id = "item-3" > Item 3</ TreeView . Item >
91
92
</ TreeView >
92
93
93
- < h2 > Trailing Actions: 2</ h2 >
94
+ < h2 > Trailing Actions: Example with dialog</ h2 >
95
+ < p > Press (Command + Shift + U) to interact with the trailing action</ p >
94
96
< TreeView aria-label = "Issues" >
95
97
< TreeView . Item id = "item-1" > Item 1</ TreeView . Item >
96
- < TrailingAction id = "item-2" >
98
+ < TrailingAction id = "item-2" dialogOnOpen = { true } >
97
99
Item 2
98
100
< TreeView . SubTree >
99
101
< TreeView . Item id = "item-2-sub-task-1" > sub task 1</ TreeView . Item >
@@ -106,14 +108,19 @@ export const TrailingActions: StoryFn = () => {
106
108
)
107
109
}
108
110
109
- const TrailingAction : React . FC < { id : string ; children : React . ReactNode } > = ( { id, children} ) => {
111
+ const TrailingAction : React . FC < { id : string ; children : React . ReactNode ; dialogOnOpen ?: boolean } > = ( {
112
+ id,
113
+ dialogOnOpen,
114
+ children,
115
+ } ) => {
110
116
const [ expanded , setExpanded ] = React . useState ( false )
111
117
const [ dialogOpen , setDialogOpen ] = React . useState ( false )
112
118
113
119
const btnRef = React . useRef < HTMLButtonElement > ( null )
114
120
115
121
const mockKeyboardShortcut = ( event : React . KeyboardEvent ) => {
116
- btnRef . current ?. focus ( )
122
+ if ( ! dialogOnOpen ) btnRef . current ?. focus ( )
123
+ if ( dialogOnOpen ) setDialogOpen ( true )
117
124
}
118
125
119
126
return (
0 commit comments