Skip to content

WheelTimePicker briefly returns current time through onTimeChangeListener #15

Description

@bburk707

While using the WheelTimePicker within an AnimatedVisibility, I noticed that the onTimeChangeListener would initially return the current time before returning the inputted startTime. This caused a flickering effect in my TextField used to display the selected time.

Implementation is shown below:

AnimatedVisibility(
    modifier = Modifier.align(Alignment.CenterHorizontally),
    visible = expanded,
    enter = expandVertically(),
    exit = shrinkVertically()
) {
    WheelTimePicker(
        height = 212.dp,
        timeFormat = TimeFormat.AM_PM,
        hideHeader = true,
        startTime = time,
        rowCount = 7,
        onTimeChangeListener = {
            println("onTimeChangeListener: $it")
            time = it
        }
    )
}

This produced the behavior shown in the following screen recording along with the print statements from within the onTimeChangeListener:

Screen.Recording.2025-09-30.at.1.06.09.PM.mov
onTimeChangeListener: 13:06:12.462928
onTimeChangeListener: 06:30
onTimeChangeListener: 13:06:14.114808
onTimeChangeListener: 06:30
onTimeChangeListener: 13:06:15.899738
onTimeChangeListener: 06:30

From first glance this may be fixed easily by initializing state variable selectedDate to the startTime on line 82 of WheelTimePickerComponent.kt

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions