Skip to content

Commit 8e643ea

Browse files
committed
add uniqueId to SfRating
1 parent 30092fd commit 8e643ea

File tree

1 file changed

+4
-3
lines changed
  • packages/qwik-storefront-ui/src/components/SfRating

1 file changed

+4
-3
lines changed

packages/qwik-storefront-ui/src/components/SfRating/SfRating.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { component$ } from '@builder.io/qwik';
1+
import { component$, useId } from '@builder.io/qwik';
22
import { SfIconStar, SfIconStarFilled, SfIconStarHalf } from '../SfIcons';
33
import { SfRatingProps, SfRatingSize } from './types';
44

@@ -20,6 +20,7 @@ export const SfRating = component$<SfRatingProps>(
2020
class: _class,
2121
...attributes
2222
}) => {
23+
const uniqueId = useId();
2324
const clamp = (value: number, min: number, max: number) => {
2425
return Math.min(Math.max(value, min), max);
2526
};
@@ -48,7 +49,7 @@ export const SfRating = component$<SfRatingProps>(
4849
<SfIconStarFilled
4950
aria-hidden="true"
5051
class="w-[1.5em] h-[1.5em]"
51-
key={'1' + i}
52+
key={`${uniqueId}-filled-${i}`}
5253
/>
5354
))}
5455
{Boolean(partiallyFilled) && (
@@ -58,7 +59,7 @@ export const SfRating = component$<SfRatingProps>(
5859
<SfIconStar
5960
aria-hidden="true"
6061
class="text-disabled-500 w-[1.5em] h-[1.5em]"
61-
key={'2' + i}
62+
key={`${uniqueId}-${i}`}
6263
/>
6364
))}
6465
</div>

0 commit comments

Comments
 (0)