Decathlon/vitamin-compose

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

Closed this issue · 2 comments

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)

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!

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.