Repository navigation
Commit b16aef1
authored
[go_router] Clarify onEnter/redirect ordering, add regression test (#12337)
## What this does
Clarifies the `onEnter` doc comment on `RoutingConfig` to explicitly warn
that `onEnter` is evaluated once, against the literal navigated-to URI,
and is never re-invoked for locations reached only through a `redirect:`
chain. Adds a regression test locking in this behavior for the exact
scenario reported in flutter/flutter#188014, plus a second test
demonstrating the correct workaround (putting the guard inside
`redirect:` instead of `onEnter`).
## Why
flutter/flutter#188014 reports what looks like a bug: an `onEnter` guard
checking for an intermediate redirect target (`/a`, reached via a
`redirect:` on `/`) never fires. Tracing the pipeline shows this is
actually intended, existing behavior — see the
`'onEnter called once when top-level redirect chains'` test (written for
the related #178984), which asserts the same ordering. The docs didn't
make this ordering/visibility gap explicit though, so it's an easy trap.
This PR closes that documentation gap and adds test coverage so the
behavior can't silently change without a test failing.
## Related
Fixes flutter/flutter#188014 (as a documentation clarification, not a
behavior change — see discussion on the issue).
## Pre-Review Checklist
> [!IMPORTANT]
> This PR was prepared with assistance from an AI agent (Claude). The
> code, doc comment, and tests have been reviewed by the author, who
> understands the change and takes responsibility for it.
[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.1 parent fd8d150 commit b16aef1
3 files changed
Lines changed: 81 additions & 0 deletions
File tree
- packages/go_router
- lib/src
- pending_changelogs
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
101 | 116 | | |
102 | 117 | | |
103 | 118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1880 | 1880 | | |
1881 | 1881 | | |
1882 | 1882 | | |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
| 1904 | + | |
| 1905 | + | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
1883 | 1947 | | |
1884 | 1948 | | |
1885 | 1949 | | |
0 commit comments