Skip to content

Commit

Permalink
fix(VFab): change type for location prop (#19949)
Browse files Browse the repository at this point in the history
fixes #19944
  • Loading branch information
SonTT19 committed Jun 11, 2024
1 parent e11d38d commit 07a6fb8
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions packages/vuetify/src/components/VFab/VFab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { makeVBtnProps, VBtn } from '@/components/VBtn/VBtn'

// Composables
import { makeLayoutItemProps, useLayoutItem } from '@/composables/layout'
import { makeLocationProps } from '@/composables/location'
import { useProxiedModel } from '@/composables/proxiedModel'
import { useResizeObserver } from '@/composables/resizeObserver'
import { useToggleScope } from '@/composables/toggleScope'
Expand All @@ -16,20 +17,14 @@ import { computed, ref, shallowRef, toRef, watchEffect } from 'vue'
import { genericComponent, omit, propsFactory, useRender } from '@/util'

// Types
import type { ComputedRef, PropType } from 'vue'
import type { ComputedRef } from 'vue'
import type { Position } from '@/composables/layout'

const locations = ['start', 'end', 'left', 'right', 'top', 'bottom'] as const

export const makeVFabProps = propsFactory({
app: Boolean,
appear: Boolean,
extended: Boolean,
layout: Boolean,
location: {
type: String as PropType<typeof locations[number]>,
default: 'bottom end',
},
offset: Boolean,
modelValue: {
type: Boolean,
Expand All @@ -38,6 +33,7 @@ export const makeVFabProps = propsFactory({

...omit(makeVBtnProps({ active: true }), ['location']),
...makeLayoutItemProps(),
...makeLocationProps(),
...makeTransitionProps({ transition: 'fab-transition' }),
}, 'VFab')

Expand Down Expand Up @@ -65,13 +61,13 @@ export const VFab = genericComponent()({
const position = computed(() => {
if (!hasPosition.value) return false

return props.location.split(' ').shift()
return props.location?.split(' ').shift() ?? 'bottom'
}) as ComputedRef<Position>

const orientation = computed(() => {
if (!hasPosition.value) return false

return props.location.split(' ')[1] ?? 'end'
return props.location?.split(' ')[1] ?? 'end'
})

useToggleScope(() => props.app, () => {
Expand Down

0 comments on commit 07a6fb8

Please sign in to comment.