Skip to content

fix: close open flows when a guard redirects the main stack - #101

Merged
Mastersam07 merged 2 commits into
devfrom
fix/close-flows-on-redirect
Nov 10, 2026
Merged

Mastersam07 merged 2 commits into
devfrom
fix/close-flows-on-redirect

Conversation

@Mastersam07

Copy link
Copy Markdown
Owner

Closes #90

When a main router guard rewrites a navigation and the main stack changes as a result, KaiselRouter now closes every open modal flow, topmost first, and each run resolves with null. Before, the flow stayed on top and hid the screen the guard sent the user to, so signing out mid flow left the flow over Login.

When flows close

  • A guard's output differs from the proposal and the main stack actually changed. This covers reevaluate / reevaluateOn (sign out, session expiry, app lock) and redirected pushes.

When they stay open

  • No guard rewrote the navigation (ordinary pushes while a flow is open).
  • A guard refused the change, so the stack stayed where it was.
  • A guard on a flow's own router redirected inside the flow.

Behaviour change. Marked as such in both changelogs. One consequence worth knowing: a lock guard that appends a passcode screen now closes an open flow too. That is the safer outcome, since before the flow covered the lock screen.

Tests

  • kaisel_core/test/kaisel_flow_redirect_test.dart: redirect via reevaluate, redirected push, nested flows, plus the three keep open cases. The three closing tests fail without the fix.
  • kaisel/test/kaisel_flow_redirect_test.dart: widget test for the issue's case, sign out mid flow with reevaluateOn; Login shows and the flow UI is gone. Without the fix it hangs on the flow result.

Docs. The guards guide and modal flows guide now describe the new behaviour and drop the dismissFlow listener workaround.

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview: https://kaisel.dev/pr-101/ (updates on every push; removed when this PR closes)

github-actions Bot pushed a commit that referenced this pull request Nov 10, 2026
@codecov

codecov Bot commented Nov 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.66%. Comparing base (84a3a08) to head (092c3b4).
⚠️ Report is 5 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev     #101   +/-   ##
=======================================
  Coverage   99.66%   99.66%           
=======================================
  Files          43       43           
  Lines        2409     2418    +9     
=======================================
+ Hits         2401     2410    +9     
  Misses          8        8           
Flag Coverage Δ
kaisel 99.66% <100.00%> (+<0.01%) ⬆️
kaisel_core 99.66% <100.00%> (+<0.01%) ⬆️
kaisel_devtools 99.66% <100.00%> (+<0.01%) ⬆️
kaisel_lint 99.66% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Mastersam07
Mastersam07 merged commit c9dc4bf into dev Nov 10, 2026
7 checks passed
github-actions Bot added a commit that referenced this pull request Nov 10, 2026
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.

Question: How to Guard a Modal?

1 participant