Skip to content

PagerState resets to initial page on configuration change (screen rotation) #31

@qamarelsafadi

Description

@qamarelsafadi

When using PagerState in a Compose screen, changing the screen orientation (triggering a configuration change) causes the PagerState to reset to its initial page (usually page 0), instead of preserving the current page index.

This behavior occurs because configuration changes recreate the screen, and PagerState is not automatically saved/restored unless explicitly handled by the developer. This leads to a poor user experience as the user loses their current position in the pager upon rotation.

Recording

Screen_recording_20250524_015546.mp4

Steps to Reproduce:

  • Swipe to any page other than the initial one (Prompt one).
  • Rotate the device (portrait to landscape).
  • Observe that the pager resets back to page 0.

Expected Behavior:

The pager should preserve and restore the current page index across configuration changes automatically, or at least provide built-in support or a recommended approach for doing so.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions