Skip to content

Commit

Permalink
fix(forwardRefs): check setupState for requested key
Browse files Browse the repository at this point in the history
fixes #15591
  • Loading branch information
KaelWD committed Aug 8, 2022
1 parent 46c5aa0 commit fae7a42
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/vuetify/src/components/VSelect/VSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const VSelect = genericComponent<new <

setup (props, { slots }) {
const { t } = useLocale()
const vTextFieldRef = ref()
const vTextFieldRef = ref<VTextField>()
const menu = useProxiedModel(props, 'menu')
const { items, transformIn, transformOut } = useItems(props)
const model = useProxiedModel(
Expand Down
8 changes: 6 additions & 2 deletions packages/vuetify/src/composables/forwardRefs.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Ref, UnwrapRef } from 'vue'
import type { ComponentPublicInstance, Ref, UnwrapRef } from 'vue'
import type { UnionToIntersection } from '@/util'

const Refs = Symbol('Forwarded refs')

export function forwardRefs<T extends {}, U extends Ref<{} | undefined>[]> (
export function forwardRefs<T extends {}, U extends Ref<HTMLElement | Omit<ComponentPublicInstance, '$emit'> | undefined>[]> (
target: T,
...refs: U
): T & UnwrapRef<UnionToIntersection<U[number]>> {
Expand Down Expand Up @@ -35,6 +35,10 @@ export function forwardRefs<T extends {}, U extends Ref<{} | undefined>[]> (
if (!ref.value) continue
const descriptor = Reflect.getOwnPropertyDescriptor(ref.value, key)
if (descriptor) return descriptor
if ('_' in ref.value && 'setupState' in ref.value._) {
const descriptor = Reflect.getOwnPropertyDescriptor(ref.value._.setupState, key)
if (descriptor) return descriptor
}
}
// Recursive search up each ref's prototype
for (const ref of refs) {
Expand Down
5 changes: 5 additions & 0 deletions packages/vuetify/src/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,14 @@ declare global {
}

declare module '@vue/runtime-core' {
export interface ComponentCustomProperties {
_: ComponentInternalInstance
}

export interface ComponentInternalInstance {
ctx: Record<string, unknown>
provides: Record<string, unknown>
setupState: any
}
}

Expand Down

0 comments on commit fae7a42

Please sign in to comment.