Skip to content

fix(#1083): animated setPage lands on wrong index - #1102

Open
troZee wants to merge 4 commits into
masterfrom
fix/1083-set-page-wrong-index
Open

fix(#1083): animated setPage lands on wrong index#1102
troZee wants to merge 4 commits into
masterfrom
fix/1083-set-page-wrong-index

Conversation

@troZee

@troZee troZee commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #1083

Test Plan

What's required for testing (prerequisites)?

What are the steps to reproduce (after prerequisites)?

Compatibility

OS Implemented
iOS ✅❌
Android ✅❌

Checklist

  • I have tested this on a device and a simulator
  • I added the documentation in README.md
  • I updated the typed files (TS and Flow)

@troZee
troZee requested review from MrRefactor and a lite review from Copilot August 15, 2026 07:42
@troZee

troZee commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator Author

@dnedo could you test this fix? I was able to check that fix locally and it works

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an iOS regression where setPage(animated: true) can land on the wrong index when invoked while a native-stack modal is being dismissed (SwiftUI TabView(selection:) animation transaction overlap).

Changes:

  • iOS: Defers animated page changes when a modal is presented, waiting for a UIKit transition coordinator before triggering the SwiftUI animation.
  • Example app: Adds a dedicated Issue #1083 reproduction flow (home + modal) and wires it into navigation.
  • E2E: Adds a Maestro regression test + setup flow to validate correct index after modal dismissal.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
ios/PagerViewProvider.swift Adds modal/presentation-aware deferral for animated page changes using transition coordination.
example/src/ModalSetPageExample.tsx Adds a minimal in-app reproduction for Issue #1083 (pager + native-stack modal).
example/src/App.tsx Registers the repro screen and modal; adjusts testIDs for the issue examples list.
.maestro/tests/issue_1083_modal_set_page_repro.yaml Adds a Maestro regression test for the modal-dismiss + setPage scenario.
.maestro/setup/issue_1083_modal_set_page_repro_setup.yaml Adds a setup flow to navigate to the new repro screen in the example app.
.gitignore Ignores .agent-device.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +183 to +192
private func hasPresentedViewController() -> Bool {
var viewController = window?.rootViewController
while let current = viewController {
if current.presentedViewController != nil {
return true
}
viewController = current.parent
}
return false
}
Comment thread example/src/App.tsx
Comment on lines 184 to 188
{ghIssues.map((example) => (
<TouchableOpacity
key={example.name}
testID={example.name}
testID={example.testID}
style={styles.exampleTouchable}
Comment on lines +127 to +131
// Native-stack begins its transition on a following run-loop pass.
// Waiting briefly lets its transition coordinator become observable.
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in
self?.setPageWhenPresentationTransitionCompletes(index: index)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS] setPage(animated) lands on wrong index when called while pager is obscured by a presented modal

2 participants