Skip to content

Commit

Permalink
use a ref in the Description comopnent
Browse files Browse the repository at this point in the history
This allows us to update the ref and everything should work after that.
Currently we only saw the "current" state.
  • Loading branch information
RobinMalfait committed Apr 30, 2021
1 parent 1529b77 commit 2f373ba
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
// Types
ComputedRef,
InjectionKey,
Ref,
} from 'vue'

import { useId } from '../../hooks/use-id'
Expand All @@ -20,7 +21,7 @@ import { render } from '../../utils/render'

let DescriptionContext = Symbol('DescriptionContext') as InjectionKey<{
register(value: string): () => void
slot: Record<string, any>
slot: Ref<Record<string, any>>
name: string
props: Record<string, any>
}>
Expand All @@ -34,11 +35,11 @@ function useDescriptionContext() {
}

export function useDescriptions({
slot = {},
slot = ref({}),
name = 'Description',
props = {},
}: {
slot?: Record<string, unknown>
slot?: Ref<Record<string, unknown>>
name?: string
props?: Record<string, unknown>
} = {}): ComputedRef<string | undefined> {
Expand Down Expand Up @@ -70,7 +71,7 @@ export let Description = defineComponent({
as: { type: [Object, String], default: 'p' },
},
render() {
let { name = 'Description', slot = {}, props = {} } = this.context
let { name = 'Description', slot = ref({}), props = {} } = this.context
let passThroughProps = this.$props
let propsWeControl = {
...Object.entries(props).reduce(
Expand All @@ -82,7 +83,7 @@ export let Description = defineComponent({

return render({
props: { ...passThroughProps, ...propsWeControl },
slot,
slot: slot.value,
attrs: this.$attrs,
slots: this.$slots,
name,
Expand Down

0 comments on commit 2f373ba

Please sign in to comment.