Skip to content

Commit

Permalink
Merge pull request #1684 from KevinnZou/kz/remove_webview_wrapper
Browse files Browse the repository at this point in the history
[Web]Remove the wrapper of webview to solve nestedscroll issue
  • Loading branch information
bentrengrove authored Jul 26, 2023
2 parents 2354722 + 3929bfb commit d484b75
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions web/src/main/java/com/google/accompanist/web/WebView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import androidx.compose.runtime.snapshotFlow
import androidx.compose.runtime.snapshots.SnapshotStateList
import androidx.compose.ui.Modifier
import androidx.compose.ui.viewinterop.AndroidView
import androidx.core.view.children
import com.google.accompanist.web.LoadingState.Finished
import com.google.accompanist.web.LoadingState.Loading
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -210,7 +209,7 @@ fun WebView(

AndroidView(
factory = { context ->
val childView = (factory?.invoke(context) ?: WebView(context)).apply {
(factory?.invoke(context) ?: WebView(context)).apply {
onCreated(this)

this.layoutParams = layoutParams
Expand All @@ -222,20 +221,10 @@ fun WebView(
webChromeClient = chromeClient
webViewClient = client
}.also { state.webView = it }

// Workaround a crash on certain devices that expect WebView to be
// wrapped in a ViewGroup.
// b/243567497
val parentLayout = FrameLayout(context)
parentLayout.layoutParams = layoutParams
parentLayout.addView(childView)

parentLayout
},
modifier = modifier,
onRelease = { parentFrame ->
val wv = parentFrame.children.first() as WebView
onDispose(wv)
onRelease = {
onDispose(it)
}
)
}
Expand Down

0 comments on commit d484b75

Please sign in to comment.