Skip to content

Commit cbd14a7

Browse files
committed
fix: replace getUid with vue's useId
fixes #19696
1 parent b244c09 commit cbd14a7

File tree

21 files changed

+65
-87
lines changed

21 files changed

+65
-87
lines changed

packages/vuetify/src/components/VCarousel/VCarousel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ type VCarouselSlots = VWindowSlots & {
5454
item: {
5555
props: Record<string, any>
5656
item: {
57-
id: number
57+
id: string
5858
value: unknown
5959
disabled: boolean | undefined
6060
}

packages/vuetify/src/components/VCheckbox/VCheckbox.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import { useFocus } from '@/composables/focus'
1010
import { useProxiedModel } from '@/composables/proxiedModel'
1111

1212
// Utilities
13-
import { computed } from 'vue'
14-
import { filterInputAttrs, genericComponent, getUid, omit, propsFactory, useRender } from '@/util'
13+
import { computed, useId } from 'vue'
14+
import { filterInputAttrs, genericComponent, omit, propsFactory, useRender } from '@/util'
1515

1616
// Types
1717
import type { VSelectionControlSlots } from '../VSelectionControl/VSelectionControl'
@@ -47,7 +47,7 @@ export const VCheckbox = genericComponent<new <T>(
4747
const model = useProxiedModel(props, 'modelValue')
4848
const { isFocused, focus, blur } = useFocus(props)
4949

50-
const uid = getUid()
50+
const uid = useId()
5151
const id = computed(() => props.id || `checkbox-${uid}`)
5252

5353
useRender(() => {

packages/vuetify/src/components/VChipGroup/VChipGroup.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ export const makeVChipGroupProps = propsFactory({
4141

4242
type VChipGroupSlots = {
4343
default: {
44-
isSelected: (id: number) => boolean
45-
select: (id: number, value: boolean) => void
44+
isSelected: (id: string) => boolean
45+
select: (id: string, value: boolean) => void
4646
next: () => void
4747
prev: () => void
48-
selected: readonly number[]
48+
selected: readonly string[]
4949
}
5050
}
5151

packages/vuetify/src/components/VField/VField.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@ import { makeRoundedProps, useRounded } from '@/composables/rounded'
1818
import { makeThemeProps, provideTheme } from '@/composables/theme'
1919

2020
// Utilities
21-
import { computed, ref, toRef, watch } from 'vue'
21+
import { computed, ref, toRef, useId, watch } from 'vue'
2222
import {
2323
animate,
2424
convertToUnit,
2525
EventProp,
2626
genericComponent,
27-
getUid,
2827
isOn,
2928
nullifyTransforms,
3029
pick,
@@ -139,7 +138,7 @@ export const VField = genericComponent<new <T>(
139138
const isActive = computed(() => props.dirty || props.active)
140139
const hasLabel = computed(() => !props.singleLine && !!(props.label || slots.label))
141140

142-
const uid = getUid()
141+
const uid = useId()
143142
const id = computed(() => props.id || `input-${uid}`)
144143
const messagesId = computed(() => `${id.value}-messages`)
145144

packages/vuetify/src/components/VInput/VInput.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import { makeThemeProps, provideTheme } from '@/composables/theme'
1515
import { makeValidationProps, useValidation } from '@/composables/validation'
1616

1717
// Utilities
18-
import { computed } from 'vue'
19-
import { EventProp, genericComponent, getUid, only, propsFactory, useRender } from '@/util'
18+
import { computed, useId } from 'vue'
19+
import { EventProp, genericComponent, only, propsFactory, useRender } from '@/util'
2020

2121
// Types
2222
import type { ComputedRef, PropType, Ref } from 'vue'
@@ -105,7 +105,7 @@ export const VInput = genericComponent<new <T>(
105105
const { rtlClasses } = useRtl()
106106
const { InputIcon } = useInputIcon(props)
107107

108-
const uid = getUid()
108+
const uid = useId()
109109
const id = computed(() => props.id || `input-${uid}`)
110110
const messagesId = computed(() => `${id.value}-messages`)
111111

packages/vuetify/src/components/VItemGroup/VItemGroup.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ export const makeVItemGroupProps = propsFactory({
2626

2727
type VItemGroupSlots = {
2828
default: {
29-
isSelected: (id: number) => boolean
30-
select: (id: number, value: boolean) => void
29+
isSelected: (id: string) => boolean
30+
select: (id: string, value: boolean) => void
3131
next: () => void
3232
prev: () => void
33-
selected: readonly number[]
33+
selected: readonly string[]
3434
}
3535
}
3636

packages/vuetify/src/components/VMenu/VMenu.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
provide,
2525
ref,
2626
shallowRef,
27+
useId,
2728
watch,
2829
} from 'vue'
2930
import { VMenuSymbol } from './shared'
@@ -32,7 +33,6 @@ import {
3233
focusChild,
3334
genericComponent,
3435
getNextElement,
35-
getUid,
3636
IN_BROWSER,
3737
isClickInsideElement,
3838
omit,
@@ -76,13 +76,13 @@ export const VMenu = genericComponent<OverlaySlots>()({
7676
const { scopeId } = useScopeId()
7777
const { isRtl } = useRtl()
7878

79-
const uid = getUid()
79+
const uid = useId()
8080
const id = computed(() => props.id || `v-menu-${uid}`)
8181

8282
const overlay = ref<VOverlay>()
8383

8484
const parent = inject(VMenuSymbol, null)
85-
const openChildren = shallowRef(new Set<number>())
85+
const openChildren = shallowRef(new Set<string>())
8686
provide(VMenuSymbol, {
8787
register () {
8888
openChildren.value.add(uid)

packages/vuetify/src/components/VRadioGroup/VRadioGroup.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import { IconValue } from '@/composables/icons'
1212
import { useProxiedModel } from '@/composables/proxiedModel'
1313

1414
// Utilities
15-
import { computed } from 'vue'
16-
import { filterInputAttrs, genericComponent, getUid, omit, propsFactory, useRender } from '@/util'
15+
import { computed, useId } from 'vue'
16+
import { filterInputAttrs, genericComponent, omit, propsFactory, useRender } from '@/util'
1717

1818
// Types
1919
import type { VInputSlots } from '@/components/VInput/VInput'
@@ -68,7 +68,7 @@ export const VRadioGroup = genericComponent<new <T>(
6868
},
6969

7070
setup (props, { attrs, slots }) {
71-
const uid = getUid()
71+
const uid = useId()
7272
const id = computed(() => props.id || `radio-group-${uid}`)
7373
const model = useProxiedModel(props, 'modelValue')
7474

packages/vuetify/src/components/VRating/VRating.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import { makeTagProps } from '@/composables/tag'
1515
import { makeThemeProps, provideTheme } from '@/composables/theme'
1616

1717
// Utilities
18-
import { computed, shallowRef } from 'vue'
19-
import { clamp, createRange, genericComponent, getUid, propsFactory, useRender } from '@/util'
18+
import { computed, shallowRef, useId } from 'vue'
19+
import { clamp, createRange, genericComponent, propsFactory, useRender } from '@/util'
2020

2121
// Types
2222
import type { Prop } from 'vue'
@@ -140,7 +140,8 @@ export const VRating = genericComponent<VRatingSlots>()({
140140
}
141141
}))
142142

143-
const name = computed(() => props.name ?? `v-rating-${getUid()}`)
143+
const uid = useId()
144+
const name = computed(() => props.name ?? `v-rating-${uid}`)
144145

145146
function VRatingItem ({ value, index, showStar = true }: { value: number, index: number, showStar?: boolean }) {
146147
const { onMouseenter, onMouseleave, onClick } = eventState.value[index + 1]

packages/vuetify/src/components/VSelectionControl/VSelectionControl.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ import { useProxiedModel } from '@/composables/proxiedModel'
1616
import { Ripple } from '@/directives/ripple'
1717

1818
// Utilities
19-
import { computed, inject, nextTick, ref, shallowRef } from 'vue'
19+
import { computed, inject, nextTick, ref, shallowRef, useId } from 'vue'
2020
import {
2121
filterInputAttrs,
2222
genericComponent,
23-
getUid,
2423
matchesSelector,
2524
propsFactory,
2625
useRender,
@@ -172,7 +171,7 @@ export const VSelectionControl = genericComponent<new <T>(
172171
backgroundColorStyles,
173172
trueValue,
174173
} = useSelectionControl(props)
175-
const uid = getUid()
174+
const uid = useId()
176175
const isFocused = shallowRef(false)
177176
const isFocusVisible = shallowRef(false)
178177
const input = ref<HTMLInputElement>()

0 commit comments

Comments
 (0)