Skip to content

Commit efa50e4

Browse files
committed
fix(VTreeview): indent-lines support for footer slot
follow-up after #22100
1 parent b7a38e1 commit efa50e4

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

packages/vuetify/src/components/VTreeview/VTreeviewChildren.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export type VTreeviewChildrenSlots<T> = {
3939
loading: boolean
4040
}
4141
footer: {
42+
props: { indentLines?: IndentLineType[] }
4243
item: T
4344
internalItem: InternalListItem<T>
4445
loading: boolean
@@ -193,6 +194,11 @@ export const VTreeviewChildren = genericComponent<new <T extends InternalListIte
193194
const treeviewGroupProps = VTreeviewGroup.filterProps(itemProps)
194195
const treeviewChildrenProps = VTreeviewChildren.filterProps({ ...props, ...treeItemProps })
195196

197+
const footerProps = {
198+
hideActions: props.hideActions,
199+
indentLines: indentLines.footer,
200+
}
201+
196202
return children ? (
197203
<VTreeviewGroup
198204
{ ...treeviewGroupProps }
@@ -205,6 +211,7 @@ export const VTreeviewChildren = genericComponent<new <T extends InternalListIte
205211
...itemProps,
206212
...activatorProps,
207213
value: itemProps?.value,
214+
hideActions: props.hideActions,
208215
indentLines: indentLines.node,
209216
onToggleExpand: [() => checkChildren(item), activatorProps.onClick] as any,
210217
onClick: isClickOnOpen.value
@@ -220,7 +227,6 @@ export const VTreeviewChildren = genericComponent<new <T extends InternalListIte
220227
ref={ el => activatorItems.value[index] = el as VTreeviewItem }
221228
{ ...listItemProps }
222229
hasCustomPrepend={ !!slots.prepend }
223-
hideActions={ props.hideActions }
224230
value={ props.returnObject ? item.raw : itemProps.value }
225231
loading={ loading }
226232
v-slots={ slotsWithItem }
@@ -239,7 +245,7 @@ export const VTreeviewChildren = genericComponent<new <T extends InternalListIte
239245
returnObject={ props.returnObject }
240246
v-slots={ slots }
241247
/>
242-
{ slots.footer?.({ item: item.raw, internalItem: item, loading }) }
248+
{ slots.footer?.({ props: footerProps, item: item.raw, internalItem: item, loading }) }
243249
</>
244250
),
245251
}}

packages/vuetify/src/util/indentLines.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export type IndentLines = {
1616
leaf: IndentLineType[] | undefined
1717
node: IndentLineType[] | undefined
1818
children: IndentLineType[] | undefined
19+
footer: IndentLineType[] | undefined
1920
}
2021

2122
export function getIndentLines ({
@@ -27,11 +28,16 @@ export function getIndentLines ({
2728
parentIndentLines,
2829
variant,
2930
}: IndentLinesOptions): IndentLines {
31+
const isLastLeaf = isLast && (!isLastGroup || separateRoots || depth > 1)
32+
3033
if (!parentIndentLines || !depth) {
3134
return {
3235
leaf: undefined,
3336
node: undefined,
3437
children: parentIndentLines,
38+
footer: parentIndentLines && (!isLastLeaf || variant === 'simple')
39+
? [...parentIndentLines, separateRoots ? 'none' : 'line']
40+
: ['none'],
3541
}
3642
}
3743

@@ -40,11 +46,10 @@ export function getIndentLines ({
4046
leaf: [...parentIndentLines, 'line'],
4147
node: [...parentIndentLines, 'line'],
4248
children: [...parentIndentLines, 'line'],
49+
footer: [...parentIndentLines, 'line', 'line'],
4350
}
4451
}
4552

46-
const isLastLeaf = isLast && (!isLastGroup || separateRoots || depth > 1)
47-
4853
return {
4954
leaf: [
5055
...parentIndentLines,
@@ -59,5 +64,9 @@ export function getIndentLines ({
5964
...parentIndentLines,
6065
isLastLeaf ? 'none' : 'line',
6166
],
67+
footer: [
68+
...parentIndentLines,
69+
isLastLeaf ? 'none' : 'line',
70+
],
6271
}
6372
}

0 commit comments

Comments
 (0)