Skip to content

onDragStopped / onDragStarted are not properly updated #102

@Nek-12

Description

@Nek-12

Inside this state, the values of onDragStarted and onDragStopped are passed downwards to a DisposableEffect. But that effect doesn't properly apply rememberUpdatedState and captures outdated versions of these lambdas in its block. As a result, the sortableList variable and all other captured variables in composition which are passed to the store in the code below are not correct.

modifier = Modifier.draggableHandle(
    enabled = state.sortingModeEnabled,
    onDragStarted = {
        haptics.performHapticFeedback(HapticFeedbackType.GestureThresholdActivate)
    },
    onDragStopped = {
        intent(FinishedReordering(sortableList))
        haptics.performHapticFeedback(HapticFeedbackType.GestureEnd)
    }
)

To fix this, properly call rememberUpdatedState on all variable references that are captured into/ passed outside the composition

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions