selected

val selected: Flow<Int>

This is a "gate-keeper" of the external data flow for all internal usage!

"External" data from TabDatabindingHook is dirty, which means there is no control, whether the index is valid (enabled and in bounds!) or not. So we have to check and correct the index for internal usage.

In order to return the corrected value to the outside, see the render method and the handling also by selectDefaultTab.

Not optimal solution, but without a buffering internal store I cannot imagine a solution with only one central location for correcting the stream.