[Pager] HorizontalPager goes to previous/next page on vertical scroll
Description Trying to use WebView composable (from Accompanist) inside HorizontalPager, when webpage is scrolled (vertically), pager tries to go to next page/ sometime even does go to next page.
Steps to reproduce Run attached sample project and vertically scroll opened webpage in webview.
@OptIn(ExperimentalPagerApi::class)
@SuppressLint("SetJavaScriptEnabled")
@Composable
fun WebViewPager() {
val pagerState = rememberPagerState()
HorizontalPager(
count = 5,
state = pagerState,
) { page ->
val webViewState = rememberWebViewState("https://duckduckgo.com/?q=${page.inc()}")
WebView(
state = webViewState,
modifier = Modifier.fillMaxSize(),
onCreated = { it.settings.javaScriptEnabled = true }
)
}
}
Expected behavior When webview/ webpage is scrolled vertically, HorizontalPager shouldn't try to go to previous/next page
Additional context
compose_compiler_version = '1.2.0'
compose_ui_version = '1.2.0-rc03'
accompanist_version = '0.24.13-rc'
kotlin 1.7.0
https://user-images.githubusercontent.com/22243296/177878788-10bd97ac-90aa-42ce-afc1-45000f57ac9b.mp4
when doing same with only compose without any AndroidView/WebView then it works fine e.g. any vertical scroll on following doesn't cause HorizontalPager trying to open page when its not wanted, one has to clearly do horizontal scroll to go to next page.
@OptIn(ExperimentalPagerApi::class)
@Composable
fun ComposePager() {
val pagerState = rememberPagerState()
HorizontalPager(
count = 5,
state = pagerState,
) { page ->
Column(
modifier = Modifier
.fillMaxSize()
.verticalScroll(state = rememberScrollState())
) {
repeat(30) {
Card(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 8.dp, vertical = 12.dp)
.wrapContentHeight()
) {
Text(
text ="Item $it",
fontSize = MaterialTheme.typography.h3.fontSize
)
}
}
}
}
}
I'm facing the same issue in a layout that includes a LazyColumn inside a pager inside a BackdropScaffold. I'm seeing random unpredictable scroll behavior on a generic user's vertical swipe, which should only scroll the lazycolumn (according to the expectations and previous behavior) This issue started only after migrating to accompanist 0.24.13 from 0.24.10
anything available that the possible couse of this? I am facing the same issue too like @Nek-12 with a scaffold containing horizontal view pager including lazy column
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Not stale
Is there a chance you can share a reproducible sample for the case when it happens without WebView?
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
I have same issue. Is there a solution?
I have same issue. Is there a solution?
@Acorde Did you try foundation pager? Maybe they fixed it there, even if it was abandoned here.
I'm using the foundation pager and this issue is still present, is there any know workaround?
Please file a bug in the main compose bug tracker with a reproducible sample. Thanks!
Couldn't this be an issue related to the WebView accompanist wrapper? In the end the issue happens with the WebView wrapper with both the old and new pager.
@andkulikov Shouldn't I file a WebView issue here instead?
EDIT I've created #1687
Right, sorry. It is indeed a WebView related issue most likely