Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(VFab): change type for location prop #19949

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading