diff --git a/dpadrecyclerview/src/main/java/com/rubensousa/dpadrecyclerview/layoutmanager/PivotLayoutManager.kt b/dpadrecyclerview/src/main/java/com/rubensousa/dpadrecyclerview/layoutmanager/PivotLayoutManager.kt index 35c5d1ed..d4dc7d7e 100644 --- a/dpadrecyclerview/src/main/java/com/rubensousa/dpadrecyclerview/layoutmanager/PivotLayoutManager.kt +++ b/dpadrecyclerview/src/main/java/com/rubensousa/dpadrecyclerview/layoutmanager/PivotLayoutManager.kt @@ -145,13 +145,13 @@ class PivotLayoutManager(properties: Properties) : RecyclerView.LayoutManager(), override fun onLayoutChildren(recycler: RecyclerView.Recycler, state: RecyclerView.State) { // If we have focus, save it temporarily since the views will change and we might lose it hadFocusBeforeLayout = hasFocus() + if (layoutInfo.isScrollingToTarget) { + scroller.cancelScrollToTarget() + } pivotLayout.onLayoutChildren(recycler, state) if (hadFocusBeforeLayout) { focusDispatcher.focusSelectedView() } - if (layoutInfo.isScrollingToTarget) { - scroller.cancelScrollToTarget() - } hadFocusBeforeLayout = false }