material-components / material-components/material-components-android
[BottomSheetDialogFragment] Weird behavior when tapping on WebView inside NestedScrollView inside BottomSheetDialogFragment
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 17.4k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
**Description:**
We have a `WebView` in a `BottomSheetDialogFragment`, and my understanding is that it’s a good idea to have it inside a `NestedScrollView` so when the bottom sheet is expanded and you scroll up in the `WebView`, you actually scroll the `WebView` content instead of dragging the bottom sheet down.
Everything works great except for this very specific thing: our `WebView` has some top margins (so the rounded corners look good), and when you tap on the `WebView`, the content immediately goes up as if there’s no top margin. It’s easier to visualize the issue in a video:
https://user-images.githubusercontent.com/750114/119615953-53321280-be00-11eb-826a-9bcb20084186.mov
So when we tap on the `WebView` (any part of its content) for the first time, we basically go from here to here:
 
And it’s like the content just scrolled for some reason, because you can scroll a bit and reach this weird state here:

The amount it scrolls always matches exactly the margin top I have in the `WebView`, and it’s always the same result regardless of how I define this space (top margin on `WebView`, padding top on `WebView` parent, `Space` widget, etc).
If instead of a `WebView` I have other kind of scrollable content, the issue doesn't seem to happen, so the issue really seems to be related to the `WebView` somehow.
**Expected behavior:** Nothing happens when I simply tap on the `WebView`.
**Source code:** https://github.com/tfcporciuncula/playground/tree/bottomsheet-issue (`bottomsheet-issue` branch)
**Android API version:** 29
**Material Library version:** 1.3.0 and 1.4.0-beta01
**Device:** Pixel 3, seems to happen consistently on any device
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked playground repository's bottomsheet-issue branch and reproduce the tap behavior on API 29 using the WebView inside NestedScrollView and BottomSheetDialogFragment. Trace the first tap and scrolling interaction, then verify that tapping the WebView no longer changes its offset or scroll position while the bottom sheet remains visually unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100