[BottomSheetDialogFragment] Weird behavior when tapping on WebView inside NestedScrollView inside BottomSheetDialogFragment #2219
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:
video.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