Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android) Fix crash with navigation on fabric #913

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.reactnativepagerview

import android.view.View
import android.view.ViewGroup
import androidx.viewpager2.widget.ViewPager2
import com.facebook.react.uimanager.PixelUtil

Expand Down Expand Up @@ -69,12 +70,19 @@ object PagerViewViewManagerImpl {
fun removeViewAt(parent: NestedScrollableHost, index: Int) {
val pager = getViewPager(parent)
val adapter = pager.adapter as ViewPagerAdapter?

val child = adapter?.getChildAt(index)

if (child != null && child.parent != null) {
(child.parent as? ViewGroup)?.removeView(child)
}

adapter?.removeChildAt(index)

// Required so ViewPager actually animates the removed view right away (otherwise
// a white screen is shown until the next user interaction).
// https://github.com/facebook/react-native/issues/17968#issuecomment-697136929
refreshViewChildrenLayout(pager)
pager.post {
pager.invalidate()
pager.requestLayout()
}
}

fun needsCustomLayoutForChildren(): Boolean {
Expand Down
Loading