Decathlon / vitamin-compose

Decathlon Design System UI components for Compose applications
https://www.decathlon.design
Apache License 2.0
268 stars 29 forks source link

fix - in VitaminTabs, if the list provided is empty, the exception 'NoSuchElementException' is thrown #72

Closed RomualdS-Decathlon closed 1 year ago

RomualdS-Decathlon commented 1 year ago

Describe the bug In VitaminTabs, if the list provided is empty, the exception 'NoSuchElementException' is thrown.

The behavior is the same for both composable (Fixed and Scrollable)

To Reproduce

VitaminTabs.Scrollable(
    tabItems = listOf(),
)

This will throw

java.util.NoSuchElementException: List is empty.
  at kotlin.collections.CollectionsKt___CollectionsKt.first(_Collections.kt:214)
  at com.decathlon.vitamin.compose.tabs.VitaminTabs.Scrollable-kKmfEb0(VitaminTabs.kt:77)
ManonPolle commented 1 year ago

Hello, @RomualdS-Decathlon, thanks for creating this issue! We will check it as soon as possible, and don't hesitate to send a PR if you want. Have a good day!

corentin-stamper commented 1 year ago

Discussed with @ManonPolle, @SimonLeclercq & @MARIEDELATTRE.

There is no point in having less than 2 entries. tabItems must therefore have at least a size of 2. If this is not the case, an exception will be thrown.