Skip to content

Commit 0bfaf12

Browse files
committed
fix(VFooter): useToggleScope for layout support
a footer shouldn't require a layout to work when not using the app prop
1 parent 349d905 commit 0bfaf12

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

packages/vuetify/src/components/VFooter/VFooter.tsx

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ import { useResizeObserver } from '@/composables/resizeObserver'
1111
import { makeRoundedProps, useRounded } from '@/composables/rounded'
1212
import { makeTagProps } from '@/composables/tag'
1313
import { makeThemeProps, provideTheme } from '@/composables/theme'
14+
import { useToggleScope } from '@/composables/toggleScope'
1415

1516
// Utilities
16-
import { computed, shallowRef, toRef } from 'vue'
17+
import { computed, ref, shallowRef, toRef, watchEffect } from 'vue'
1718
import { convertToUnit, genericComponent, propsFactory, useRender } from '@/util'
1819

1920
export const makeVFooterProps = propsFactory({
@@ -39,6 +40,9 @@ export const VFooter = genericComponent()({
3940
props: makeVFooterProps(),
4041

4142
setup (props, { slots }) {
43+
const layoutItemStyles = ref()
44+
const layoutIsReady = shallowRef()
45+
4246
const { themeClasses } = provideTheme(props)
4347
const { backgroundColorClasses, backgroundColorStyles } = useBackgroundColor(toRef(props, 'color'))
4448
const { borderClasses } = useBorder(props)
@@ -51,14 +55,22 @@ export const VFooter = genericComponent()({
5155
autoHeight.value = entries[0].target.clientHeight
5256
})
5357
const height = computed(() => props.height === 'auto' ? autoHeight.value : parseInt(props.height, 10))
54-
const { layoutItemStyles, layoutIsReady } = useLayoutItem({
55-
id: props.name,
56-
order: computed(() => parseInt(props.order, 10)),
57-
position: computed(() => 'bottom'),
58-
layoutSize: height,
59-
elementSize: computed(() => props.height === 'auto' ? undefined : height.value),
60-
active: computed(() => props.app),
61-
absolute: toRef(props, 'absolute'),
58+
59+
useToggleScope(() => props.app, () => {
60+
const layout = useLayoutItem({
61+
id: props.name,
62+
order: computed(() => parseInt(props.order, 10)),
63+
position: computed(() => 'bottom'),
64+
layoutSize: height,
65+
elementSize: computed(() => props.height === 'auto' ? undefined : height.value),
66+
active: computed(() => props.app),
67+
absolute: toRef(props, 'absolute'),
68+
})
69+
70+
watchEffect(() => {
71+
layoutItemStyles.value = layout.layoutItemStyles.value
72+
layoutIsReady.value = layout.layoutIsReady
73+
})
6274
})
6375

6476
useRender(() => (
@@ -84,7 +96,7 @@ export const VFooter = genericComponent()({
8496
/>
8597
))
8698

87-
return props.app ? layoutIsReady : {}
99+
return props.app ? layoutIsReady.value : {}
88100
},
89101
})
90102

0 commit comments

Comments
 (0)