accompanist icon indicating copy to clipboard operation
accompanist copied to clipboard

[Pager] When rememberSaveable has input, the width of the item will change currentPage.

Open FishHawk opened this issue 3 years ago • 3 comments

Description I have a pointer variable and I want to recreate the PagerState when it changes, like this:

val state = rememberSaveable(pointer, saver = PagerState.Saver) { PagerState() }
  HorizontalPager(
      count = 10,
      modifier = Modifier.fillMaxSize(),
      state = state,
  ) {
      Text(text = "Chapter is empty")
  }

When the width of the HorizontalPager's content is sufficient, everything works fine. But if the width is small, like this:

Text(text = "Chapter is")

Every time the pointer changes, it will trigger three recompose, each time the currentPage is 0,2,0.

When the content is more complex, there seems to be some sort of competition between the last two compose, causing the page to jump to the third page incorrectly.

Additional context composeVersion = 1.3.0-alpha01 accompanistVersion = 0.24.13-rc

FishHawk avatar Jul 17 '22 07:07 FishHawk

What do you mean by "content is sufficient"? Is there a chance you can try to come up with a sample fully reproducing the issue you described?

andkulikov avatar Jul 20 '22 16:07 andkulikov

Here is a sample: https://github.com/FishHawk/accompanist-issue-1249 Toggle the pager size and see how the currentPage changes.

FishHawk avatar Jul 25 '22 03:07 FishHawk

Like this: https://user-images.githubusercontent.com/46566858/180692942-624ead0c-fe1b-4114-85b9-c2b5525c3de7.mp4

FishHawk avatar Jul 25 '22 03:07 FishHawk

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.

github-actions[bot] avatar Aug 24 '22 03:08 github-actions[bot]