@@ -150,7 +150,7 @@ const rowBackgroundColor = {
150
150
}
151
151
} as const ;
152
152
153
- const treeRow = style < TreeRowRenderProps > ( {
153
+ const treeRow = style ( {
154
154
position : 'relative' ,
155
155
display : 'flex' ,
156
156
height : 40 ,
@@ -159,6 +159,9 @@ const treeRow = style<TreeRowRenderProps>({
159
159
boxSizing : 'border-box' ,
160
160
font : 'ui' ,
161
161
color : 'body' ,
162
+ borderRadius : { // odd behaviour, if this is the last property, then bottom right isn't rounded
163
+ isDetached : 'default'
164
+ } ,
162
165
outlineStyle : 'none' ,
163
166
cursor : {
164
167
default : 'default' ,
@@ -219,6 +222,17 @@ const treeContent = style({
219
222
overflow : 'hidden'
220
223
} ) ;
221
224
225
+ const cellFocus = {
226
+ outlineStyle : {
227
+ default : 'none' ,
228
+ isFocusVisible : 'solid'
229
+ } ,
230
+ outlineOffset : - 2 ,
231
+ outlineWidth : 2 ,
232
+ outlineColor : 'focus-ring' ,
233
+ borderRadius : '[6px]'
234
+ } as const ;
235
+
222
236
export const TreeViewItem = < T extends object > ( props : TreeViewItemProps < T > ) => {
223
237
let {
224
238
children,
@@ -230,7 +244,7 @@ export const TreeViewItem = <T extends object>(props: TreeViewItemProps<T>) => {
230
244
let content ;
231
245
let nestedRows ;
232
246
let { renderer} = useTreeRendererContext ( ) ;
233
- // let {isDetached} = useContext(InternalTreeContext);
247
+ let { isDetached} = useContext ( InternalTreeContext ) ;
234
248
// TODO alternative api is that we have a separate prop for the TreeItems contents and expect the child to then be
235
249
// a nested tree item
236
250
@@ -262,10 +276,11 @@ export const TreeViewItem = <T extends object>(props: TreeViewItemProps<T>) => {
262
276
{ ...props }
263
277
className = { renderProps => treeRow ( {
264
278
...renderProps ,
279
+ isDetached,
265
280
isLink : ! ! href
266
- } ) + ( renderProps . isFocusVisible && ' ' + raw ( '&:before { content: ""; display: inline-block; position: sticky; inset-inline-start: 0; width: 3px; height: 100%; margin-inline-end: -3px; margin-block-end: 1px; z-index: 3; background-color: var(--rowFocusIndicatorColor)' ) ) } >
281
+ } ) + ( renderProps . isFocusVisible && ! isDetached && ' ' + raw ( '&:before { content: ""; display: inline-block; position: sticky; inset-inline-start: 0; width: 3px; height: 100%; margin-inline-end: -3px; margin-block-end: 1px; z-index: 3; background-color: var(--rowFocusIndicatorColor)' ) ) } >
267
282
< UNSTABLE_TreeItemContent >
268
- { ( { isExpanded, hasChildRows, selectionMode, selectionBehavior, isDisabled} ) => (
283
+ { ( { isExpanded, hasChildRows, selectionMode, selectionBehavior, isDisabled, isFocusVisible } ) => (
269
284
< div className = { treeCellGrid ( { isDisabled} ) } >
270
285
{ selectionMode !== 'none' && selectionBehavior === 'toggle' && (
271
286
// TODO: add transition?
@@ -289,6 +304,7 @@ export const TreeViewItem = <T extends object>(props: TreeViewItemProps<T>) => {
289
304
] } >
290
305
{ content }
291
306
</ Provider >
307
+ { isFocusVisible && isDetached && < div role = "presentation" className = { style ( { ...cellFocus , position : 'absolute' , inset : 0 } ) ( { isFocusVisible : true } ) } /> }
292
308
</ div >
293
309
) }
294
310
</ UNSTABLE_TreeItemContent >
0 commit comments