Skip to content

Commit

Permalink
[klistnode] Overrides performScrollToIndex action to a more reliable …
Browse files Browse the repository at this point in the history
…solution
  • Loading branch information
PStrelchenko committed Jun 23, 2024
1 parent b5e8333 commit b60f80e
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,28 @@ class KListNode(
lengthSemanticsPropertyKey = lengthSemanticsPropertyKey,
)

// region Overriding base node actions

/**
* Performs scroll to position with [index].
*
* We have to override this action from [io.github.kakaocup.compose.node.action.NodeActions], because not every
* scrollable container has [androidx.compose.ui.semantics.SemanticsActions.ScrollToIndex] action.
* Using [androidx.compose.ui.semantics.SemanticsActions.ScrollBy] action is a more reliable solution
* with child Matcher on item index.
*
* @throws NullPointerException if [itemIndexSemanticsPropertyKey] is `null`.
* @throws [IllegalStateException] if this node marked as not scrollable (see [isScrollable]).
* @throws [AssertionError] if node doesn't have [androidx.compose.ui.semantics.SemanticsActions.ScrollBy] action.
*/
@OptIn(ExperimentalTestApi::class)
override fun performScrollToIndex(index: Int) {
check(isScrollable)
getItemAt(0)
}

// endregion

// region Methods for checking the existence / non-existence of items in the list

/**
Expand Down

0 comments on commit b60f80e

Please sign in to comment.