Skip to content

Commit

Permalink
fix(VFooter): useToggleScope for layout support
Browse files Browse the repository at this point in the history
a footer shouldn't require a layout to work when not using the app prop
  • Loading branch information
johnleider committed Jul 26, 2024
1 parent 349d905 commit 0bfaf12
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions packages/vuetify/src/components/VFooter/VFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import { useResizeObserver } from '@/composables/resizeObserver'
import { makeRoundedProps, useRounded } from '@/composables/rounded'
import { makeTagProps } from '@/composables/tag'
import { makeThemeProps, provideTheme } from '@/composables/theme'
import { useToggleScope } from '@/composables/toggleScope'

// Utilities
import { computed, shallowRef, toRef } from 'vue'
import { computed, ref, shallowRef, toRef, watchEffect } from 'vue'
import { convertToUnit, genericComponent, propsFactory, useRender } from '@/util'

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

setup (props, { slots }) {
const layoutItemStyles = ref()
const layoutIsReady = shallowRef()

const { themeClasses } = provideTheme(props)
const { backgroundColorClasses, backgroundColorStyles } = useBackgroundColor(toRef(props, 'color'))
const { borderClasses } = useBorder(props)
Expand All @@ -51,14 +55,22 @@ export const VFooter = genericComponent()({
autoHeight.value = entries[0].target.clientHeight
})
const height = computed(() => props.height === 'auto' ? autoHeight.value : parseInt(props.height, 10))
const { layoutItemStyles, layoutIsReady } = useLayoutItem({
id: props.name,
order: computed(() => parseInt(props.order, 10)),
position: computed(() => 'bottom'),
layoutSize: height,
elementSize: computed(() => props.height === 'auto' ? undefined : height.value),
active: computed(() => props.app),
absolute: toRef(props, 'absolute'),

useToggleScope(() => props.app, () => {
const layout = useLayoutItem({
id: props.name,
order: computed(() => parseInt(props.order, 10)),
position: computed(() => 'bottom'),
layoutSize: height,
elementSize: computed(() => props.height === 'auto' ? undefined : height.value),
active: computed(() => props.app),
absolute: toRef(props, 'absolute'),
})

watchEffect(() => {
layoutItemStyles.value = layout.layoutItemStyles.value
layoutIsReady.value = layout.layoutIsReady
})
})

useRender(() => (
Expand All @@ -84,7 +96,7 @@ export const VFooter = genericComponent()({
/>
))

return props.app ? layoutIsReady : {}
return props.app ? layoutIsReady.value : {}
},
})

Expand Down

0 comments on commit 0bfaf12

Please sign in to comment.