fix(spa): list-action redirect refresh + popup-blocked fallback (#644) + 1.5.1#646
Merged
MartinCastroAlvarez merged 1 commit intoMay 31, 2026
Conversation
… + 1.5.1 ## #644 — list-page action redirect parity Two real gaps in how the changelist bulk-action handler treated a `result.redirect` envelope: 1. **No `await refresh()` on the redirect path.** Per Django admin's `ModelAdmin.response_action` contract, an action that returns a redirect can ALSO have applied side-effects to the rows (`reprocess + redirect to status page`, `regenerate + redirect to download`, …). The previous code `return`-ed before refresh, so those side-effects weren't reflected until the next manual reload. 2. **Popup-blocker silently swallowed the redirect.** `window.open` returns `null` when the call happens past the direct-user-gesture moment (we're inside an async continuation after the POST resolves). The previous code ignored that null, so the operator saw the toast "opened in a new tab" but nothing opened. Fix: - `window.open` return value checked. On `null`, render an amber fallback banner with a clickable link (`<a target="_blank" rel="noopener noreferrer">`) so the redirect URL is never lost. Dismiss button clears the banner. - `refresh()` now fires on BOTH branches. - Generic "<action> — N item(s)" success toast suppressed on the redirect path — the redirect's destination usually surfaces the next-step UX, so an extra "Done" toast adds noise. Extracted `handleActionResult(...)` as a pure helper next to `ListPage.tsx` so the redirect / popup-blocked / refresh / messages- toast flow is unit-testable without rendering the whole page. Seven new vitests cover every branch. ## Dep bump `django-admin-rest-api ^1.1.0` → resolved to **1.1.1** in the lock (README sync of the security improvements that landed in 1.0.7+ — actions runner DoS guard + history field-name redaction + settings hygiene system checks). ## Verification - `pnpm test` — **194 / 194 ✓** (up from 187; +7 new) - `pnpm -r typecheck` ✓ - `pnpm lint` ✓ - `pnpm -w build` ✓ Closes #644. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #644.
What was wrong
Two real gaps in how the changelist bulk-action handler treated a
result.redirectenvelope from the API runner:No
await refresh()on the redirect path. Per Django admin'sModelAdmin.response_actioncontract, an action that returns a redirect can ALSO have applied side-effects to the rows (reprocess + redirect to status page,regenerate + redirect to download, …). The previous codereturn-ed before refresh, so those side-effects weren't reflected until the next manual reload.Popup-blocker silently swallowed the redirect.
window.openreturnsnullwhen the call happens past the direct-user-gesture moment (we're inside an async continuation after the POST resolves). The previous code ignored that null, so the operator saw "opened in a new tab" but nothing opened.Fix
window.openreturn value checked. Onnull, render an amber fallback banner with a clickable link (<a target="_blank" rel="noopener noreferrer">) so the redirect URL is never lost. Dismiss button clears the banner.refresh()now fires on BOTH branches.The redirect path itself still uses
noopener,noreferrer(reverse-tabnabbing + referer-leak defence) per the issue's stated security stance — those flags were already there.Refactor for testability
Extracted
handleActionResult(...)as a pure helper next toListPage.tsxso the redirect / popup-blocked / refresh / messages-toast flow is unit-testable without rendering the whole page.window.openandsetPendingRedirectare dependency-injected (openLink,onPopupBlockedargs) so the test suite can lock the branching without touching jsdom's non-configurable navigation surface.Dep bump
django-admin-rest-api ^1.1.0constraint resolved to 1.1.1 in the lock (the README-sync release that documents the security improvements landed in 1.0.7+ — actions runner DoS guard + history field-name redaction + settings hygiene checks).Verification
pnpm test— 194 / 194 ✓ (up from 187; +7 new inaction-result.test.ts)pnpm -r typecheck✓pnpm lint✓pnpm -w build✓The seven new tests cover:
messages[]toasts by level (error → red, info → blue, success → green).What's NOT in this PR
🤖 Generated with Claude Code