carbon-design-system / carbon-components-svelte

Svelte implementation of the Carbon Design System
https://svelte.carbondesignsystem.com
Apache License 2.0
2.71k stars 261 forks source link

SkeletonText lines carry over from other instances in some cases #1793

Closed rendall closed 1 year ago

rendall commented 1 year ago

https://github.com/carbon-design-system/carbon-components-svelte/blob/a1c7d9bd7c0de5b7321f745b8b85dee5682728aa/src/SkeletonText/SkeletonText.svelte#L16-L26

In svelte lists e.g.

{#each list as item}
  <SkeletonText paragraph lines={2} />
{/each}

the number of lines can carry over from the previous instance in the list. That is, in this example, the first instance will have 2 elements in rows, the second will have 4 and so on.

The reason is that rows is a reactive declaration, which will share its value with other members of the list. This behavior is a quirk of Svelte and not necessarily intuitive, but the number of lines is therefore not necessarily determined by the lines prop. I recommend inserting a

rows=[]

just after line 19.

Or possibly changing $:rows = [] to let rows = [] depending on expected use cases.

metonym commented 1 year ago

Fixed in v0.80.0