Skip to content

Commit

Permalink
fix(VSnackbar): conditionally load layout styles
Browse files Browse the repository at this point in the history
closes #19717
  • Loading branch information
johnleider committed Apr 30, 2024
1 parent b9a588f commit 9504efa
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/vuetify/src/components/VSnackbar/VSnackbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ import { VProgressLinear } from '@/components/VProgressLinear'
// Composables
import { useLayout } from '@/composables'
import { forwardRefs } from '@/composables/forwardRefs'
import { VuetifyLayoutKey } from '@/composables/layout'
import { makeLocationProps } from '@/composables/location'
import { makePositionProps, usePosition } from '@/composables/position'
import { useProxiedModel } from '@/composables/proxiedModel'
import { makeRoundedProps, useRounded } from '@/composables/rounded'
import { useScopeId } from '@/composables/scopeId'
import { makeThemeProps, provideTheme } from '@/composables/theme'
import { useToggleScope } from '@/composables/toggleScope'
import { genOverlays, makeVariantProps, useVariant } from '@/composables/variant'

// Utilities
import { computed, mergeProps, nextTick, onMounted, onScopeDispose, ref, shallowRef, watch } from 'vue'
import { computed, inject, mergeProps, nextTick, onMounted, onScopeDispose, ref, shallowRef, watch, watchEffect } from 'vue'
import { genericComponent, omit, propsFactory, refElement, useRender } from '@/util'

type VSnackbarSlots = {
Expand Down Expand Up @@ -96,7 +98,6 @@ export const VSnackbar = genericComponent<VSnackbarSlots>()({

setup (props, { slots }) {
const isActive = useProxiedModel(props, 'modelValue')
const { mainStyles } = useLayout()
const { positionClasses } = usePosition(props)
const { scopeId } = useScopeId()
const { themeClasses } = provideTheme(props)
Expand All @@ -108,6 +109,16 @@ export const VSnackbar = genericComponent<VSnackbarSlots>()({
const timerRef = ref<VProgressLinear>()
const isHovering = shallowRef(false)
const startY = shallowRef(0)
const mainStyles = ref()
const hasLayout = inject(VuetifyLayoutKey, undefined)

useToggleScope(() => !!hasLayout, () => {
const layout = useLayout()

watchEffect(() => {
mainStyles.value = layout.mainStyles.value
})
})

watch(isActive, startTimeout)
watch(() => props.timeout, startTimeout)
Expand Down

0 comments on commit 9504efa

Please sign in to comment.