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 WebView scrolling in BottomSheet #261

Merged
merged 1 commit into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
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
Expand Up @@ -6,6 +6,7 @@ import android.util.AttributeSet
import android.webkit.WebView
import android.widget.FrameLayout
import android.widget.FrameLayout.LayoutParams.MATCH_PARENT
import android.widget.FrameLayout.LayoutParams.WRAP_CONTENT
import androidx.webkit.WebViewCompat
import dev.hotwire.turbo.util.contentFromAsset
import dev.hotwire.turbo.util.runOnUiThread
Expand All @@ -28,7 +29,7 @@ open class TurboWebView @JvmOverloads constructor(context: Context, attrs: Attri
settings.javaScriptEnabled = true
settings.domStorageEnabled = true
settings.setSupportMultipleWindows(true)
layoutParams = FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)
layoutParams = FrameLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT)
jayohms marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
17 changes: 9 additions & 8 deletions turbo/src/main/res/layout/turbo_view.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<dev.hotwire.turbo.views.TurboView
xmlns:android="http://schemas.android.com/apk/res/android"
<dev.hotwire.turbo.views.TurboView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/turbo_view"
android:layout_width="match_parent"
Expand All @@ -9,7 +8,8 @@
<dev.hotwire.turbo.views.TurboSwipeRefreshLayout
android:id="@+id/turbo_webView_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:fillViewport="true">

<!-- WebView get attached/detached here -->

Expand All @@ -19,9 +19,9 @@
android:id="@+id/turbo_progress_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:clickable="true"
android:focusable="true">
android:focusable="true"
android:visibility="gone">

<!-- Custom progress view added/removed here -->

Expand All @@ -31,19 +31,20 @@
android:id="@+id/turbo_screenshot"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:clickable="true"
android:focusable="true"
android:scaleType="fitStart"
android:visibility="gone"
tools:ignore="ContentDescription" />

<dev.hotwire.turbo.views.TurboSwipeRefreshLayout
android:id="@+id/turbo_error_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:clickable="true"
android:focusable="true">
android:fillViewport="true"
android:focusable="true"
android:visibility="gone">

<ScrollView
android:id="@+id/turbo_error_container"
Expand Down
5 changes: 3 additions & 2 deletions turbo/src/main/res/layout/turbo_view_bottom_sheet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<FrameLayout
<androidx.core.widget.NestedScrollView
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WebView hasn't always played nicely with NestedScrollView, but maybe that's been resolved over the last couple years. We'll want to test this thoroughly. Can you make sure that we're using the latest androidx dependency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There don't seem to be any issues with this anymore 🤞

I updated all the dependencies in a separate PR (#262) and there don't seem to be any issues.

android:id="@+id/turbo_webView_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:minHeight="400dp">

<!-- WebView get attached/detached here -->

</FrameLayout>
</androidx.core.widget.NestedScrollView>

<FrameLayout
android:id="@+id/turbo_progress_container"
Expand Down