ref(api): migrate auth-error navigation off browserHistory#115935
Conversation
📊 Type Coverage Diff✅ No new type safety issues introduced. Coverage: 93.57% |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 655c66c. Configure here.
|
|
||
| if (EXPERIMENTAL_SPA) { | ||
| browserHistory.replace('/auth/login/'); | ||
| apiNavigate?.('/auth/login/', {replace: true}); |
There was a problem hiding this comment.
Auth replace drops scroll behavior
Low Severity
The auth-error paths now call apiNavigate with only {replace: true}, but the removed browserHistory.replace shim always passed preventScrollReset: true on replace. Session-expiry and member-limit redirects can now reset scroll differently than before.
Reviewed by Cursor Bugbot for commit 655c66c. Configure here.
|
|
||
| if (EXPERIMENTAL_SPA) { | ||
| browserHistory.replace('/auth/login/'); | ||
| apiNavigate?.('/auth/login/', {replace: true}); |
There was a problem hiding this comment.
Tests skip api navigate setup
Medium Severity
Auth errors now depend on setApiNavigate, but the shared test render helper still only calls DANGEROUS_SET_REACT_ROUTER_6_HISTORY. Tests that mount App, register initApiClientErrorHandling, and hit a 401 will treat the error as handled while navigation no-ops.
Reviewed by Cursor Bugbot for commit 655c66c. Configure here.
`api.tsx` is consumed outside React, so it can't use the `useNavigate` hook. Replace its two `browserHistory.replace` calls with a once-cell pattern: api.tsx exports `setApiNavigate`, which the app bootstrap calls alongside `DANGEROUS_SET_REACT_ROUTER_6_HISTORY` with a `ReactRouter3Navigate`-compatible function built from the router. Adds `createReactRouter3Navigate(router)` in `useNavigate.tsx` so the same helper can be reused if other non-React modules ever need an imperative navigate.
655c66c to
0123c3b
Compare
`api.tsx` is consumed outside React, so it can't use the `useNavigate` hook. Replace its two `browserHistory.replace` calls with a once-cell pattern: - `api.tsx` exports `setApiNavigate(navigate)` which stores a module-level `ReactRouter3Navigate` function. - The app bootstrap (`static/app/main.tsx` and `static/gsAdmin/init.tsx`) calls it alongside `DANGEROUS_SET_REACT_ROUTER_6_HISTORY` with a navigate function built from the router. - The auth-error handler invokes the stored navigate (or no-ops if not yet installed). `createReactRouter3Navigate(router)` is added to `useNavigate.tsx` so any other non-React module that needs an imperative navigate can reuse the same helper.


api.tsxis consumed outside React, so it can't use theuseNavigatehook. Replace its twobrowserHistory.replacecalls with a once-cell pattern:api.tsxexportssetApiNavigate(navigate)which stores a module-levelReactRouter3Navigatefunction.static/app/main.tsxandstatic/gsAdmin/init.tsx) calls it alongsideDANGEROUS_SET_REACT_ROUTER_6_HISTORYwith a navigate function built from the router.createReactRouter3Navigate(router)is added touseNavigate.tsxso any other non-React module that needs an imperative navigate can reuse the same helper.