Skip to content

Commit

Permalink
fix(VRadioGroup): remove multiple prop (#15910)
Browse files Browse the repository at this point in the history
fixes #15559
  • Loading branch information
jacekkarczmarczyk committed Oct 17, 2022
1 parent dc496a4 commit 32cb6ba
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
9 changes: 6 additions & 3 deletions packages/vuetify/src/components/VRadioGroup/VRadioGroup.tsx
Expand Up @@ -14,7 +14,7 @@ import { useProxiedModel } from '@/composables/proxiedModel'

// Utilities
import { computed, toRef } from 'vue'
import { defineComponent, filterInputAttrs, getUid, useRender } from '@/util'
import { defineComponent, excludeProps, filterInputAttrs, getUid, useRender } from '@/util'

export const VRadioGroup = defineComponent({
name: 'VRadioGroup',
Expand All @@ -28,7 +28,7 @@ export const VRadioGroup = defineComponent({
},

...makeVInputProps(),
...makeSelectionControlProps(),
...excludeProps(makeSelectionControlProps(), ['multiple']),

trueIcon: {
type: IconValue,
Expand Down Expand Up @@ -63,7 +63,10 @@ export const VRadioGroup = defineComponent({
useRender(() => {
const [inputAttrs, controlAttrs] = filterInputAttrs(attrs)
const [inputProps, _1] = filterInputProps(props)
const [controlProps, _2] = filterControlProps(props)
const [controlProps, _2] = filterControlProps({
...props,
multiple: false as const,
})
const label = slots.label
? slots.label({
label: props.label,
Expand Down
11 changes: 10 additions & 1 deletion packages/vuetify/src/util/__tests__/propsFactory.spec.ts
@@ -1,4 +1,4 @@
import { propsFactory } from '../propsFactory'
import { excludeProps, propsFactory } from '../propsFactory'
import { describe, expect, it } from '@jest/globals'

describe('propsFactory', () => {
Expand Down Expand Up @@ -30,4 +30,13 @@ describe('propsFactory', () => {
propsFactory({ foo: definition }, source)()
).toStrictEqual({ foo: result })
})

it('should remove excluded props', () => {
const props = propsFactory({ foo: String, bar: Number })()

// @ts-expect-error
excludeProps(props, ['baz'])

expect(excludeProps(props, ['foo'])).toStrictEqual({ bar: { type: Number } })
})
})
11 changes: 11 additions & 0 deletions packages/vuetify/src/util/propsFactory.ts
Expand Up @@ -54,6 +54,17 @@ export function propsFactory<
}
}

export function excludeProps<
PropsOptions extends ComponentObjectPropsOptions,
ExcludeProps extends keyof PropsOptions
> (props: PropsOptions, exclude: ExcludeProps[]): Omit<PropsOptions, ExcludeProps> {
const clone = { ...props }

exclude.forEach(prop => delete clone[prop])

return clone
}

type AppendDefault<T extends ComponentObjectPropsOptions, D extends PartialKeys<T>> = {
[P in keyof T]-?: unknown extends D[P]
? T[P]
Expand Down

0 comments on commit 32cb6ba

Please sign in to comment.