@@ -17,7 +17,7 @@ import ChevronLeftMedium from '@spectrum-icons/ui/ChevronLeftMedium';
17
17
import ChevronRightMedium from '@spectrum-icons/ui/ChevronRightMedium' ;
18
18
import { DOMRef , Expandable , Key , SelectionBehavior , SpectrumSelectionProps , StyleProps } from '@react-types/shared' ;
19
19
import { isAndroid } from '@react-aria/utils' ;
20
- import React , { createContext , JSX , JSXElementConstructor , ReactElement , ReactNode , useContext , useRef } from 'react' ;
20
+ import React , { createContext , JSX , JSXElementConstructor , ReactElement , ReactNode , useRef } from 'react' ;
21
21
import { SlotProvider , useDOMRef , useStyleProps } from '@react-spectrum/utils' ;
22
22
import { style } from '@react-spectrum/style-macro-s1' with { type : 'macro' } ;
23
23
import { useButton } from '@react-aria/button' ;
@@ -40,8 +40,6 @@ export interface SpectrumTreeViewProps<T> extends Omit<AriaTreeGridListProps<T>,
40
40
export interface SpectrumTreeViewItemProps < T extends object = object > extends Omit < TreeItemProps , 'className' | 'style' | 'value' | 'onHoverStart' | 'onHoverEnd' | 'onHoverChange' > {
41
41
/** Rendered contents of the tree item or child items. */
42
42
children : ReactNode ,
43
- /** Whether this item has children, even if not loaded yet. */
44
- hasChildItems ?: boolean ,
45
43
/** A list of child tree item objects used when dynamically rendering the tree item children. */
46
44
childItems ?: Iterable < T >
47
45
}
@@ -219,23 +217,18 @@ const treeRowOutline = style({
219
217
}
220
218
} ) ;
221
219
222
- let TreeItemContext = createContext < { hasChildItems ?: boolean } > ( { } ) ;
223
-
224
220
export const TreeViewItem = < T extends object > ( props : SpectrumTreeViewItemProps < T > ) => {
225
221
let {
226
222
href
227
223
} = props ;
228
224
229
225
return (
230
- // TODO right now all the tree rows have the various data attributes applied on their dom nodes, should they? Doesn't feel very useful
231
- < TreeItemContext . Provider value = { { hasChildItems : ! ! props . childItems || props . hasChildItems } } >
232
- < UNSTABLE_TreeItem
233
- { ...props }
234
- className = { renderProps => treeRow ( {
235
- ...renderProps ,
236
- isLink : ! ! href
237
- } ) } />
238
- </ TreeItemContext . Provider >
226
+ < UNSTABLE_TreeItem
227
+ { ...props }
228
+ className = { renderProps => treeRow ( {
229
+ ...renderProps ,
230
+ isLink : ! ! href
231
+ } ) } />
239
232
) ;
240
233
} ;
241
234
@@ -244,7 +237,6 @@ export const TreeItemContent = (props: Omit<TreeItemContentProps, 'children'> &
244
237
let {
245
238
children
246
239
} = props ;
247
- let { hasChildItems} = useContext ( TreeItemContext ) ;
248
240
249
241
return (
250
242
< UNSTABLE_TreeItemContent >
@@ -260,7 +252,7 @@ export const TreeItemContent = (props: Omit<TreeItemContentProps, 'children'> &
260
252
) }
261
253
< div style = { { gridArea : 'level-padding' , marginInlineEnd : `calc(${ level - 1 } * var(--spectrum-global-dimension-size-200))` } } />
262
254
{ /* TODO: revisit when we do async loading, at the moment hasChildItems will only cause the chevron to be rendered, no aria/data attributes indicating the row's expandability are added */ }
263
- { ( hasChildRows || hasChildItems ) && < ExpandableRowChevron isDisabled = { isDisabled } isExpanded = { isExpanded } /> }
255
+ { hasChildRows && < ExpandableRowChevron isDisabled = { isDisabled } isExpanded = { isExpanded } /> }
264
256
< SlotProvider
265
257
slots = { {
266
258
text : { UNSAFE_className : treeContent ( { isDisabled} ) } ,
@@ -278,9 +270,7 @@ export const TreeItemContent = (props: Omit<TreeItemContentProps, 'children'> &
278
270
} ,
279
271
actionMenu : { UNSAFE_className : treeActionMenu ( ) , UNSAFE_style : { marginInlineEnd : '.5rem' } , isQuiet : true }
280
272
} } >
281
- < TreeItemContext . Provider value = { { } } >
282
- { children }
283
- </ TreeItemContext . Provider >
273
+ { children }
284
274
</ SlotProvider >
285
275
< div className = { treeRowOutline ( { isFocusVisible, isSelected} ) } />
286
276
</ div >
0 commit comments