Repository navigation
fix(#192): keep the Modal action pending state through a rejection - #193
lablup-quill[bot] wants to merge 7 commits into
Conversation
PR Analysis Report📚 Storybook PreviewGitHub Pages may take up to a minute to hydrate after the deploy. 🧩 Changed Components
📦 Bundle Size
Total gzip (JS + CSS): 220.4 kB (+0.0 kB vs Generated by the PR Preview workflow for |
|
Preview published under the pnpm add @lablup/ui-common@0.2.1-pr-193-20261203134244-93e408945
pnpm add -D @lablup/ui-common-cli@0.2.1-pr-193-20261203134244-93e408945In backend.ai-webui: |
| label={actionLabel ?? t("uic.common.ok")} | ||
| isLoading={isActionLoading ?? actionButtonProps?.isLoading} | ||
| isDisabled={isActionDisabled ?? actionButtonProps?.isDisabled} | ||
| clickAction={async () => { |
There was a problem hiding this comment.
[Pre-existing]
Only this call site guards its clickAction; ConfirmPopover.tsx:158 and DataGridExportModal.tsx:210 (and any future one) still await a caller's promise bare, so they keep producing the same uncaught error this PR removes from Modal.
How to show it fails: Make ConfirmPopover's onAction or DataGridExportModal's onExport reject: React reports an uncaught error, exactly as Modal did before this PR.
There was a problem hiding this comment.
needs-human — confirmed: ConfirmPopover.tsx:158 and DataGridExportModal.tsx:210 await a caller's promise in clickAction with no catch, so they keep the same uncaught-error path. Fixing them here (with tests), factoring a shared helper, or taking a follow-up is a scope call for the owner, so this thread stays open for that decision.
|
4 findings — 1 Important, 3 Nit, 0 Pre-existing Round 2 —
|
| # | Tag | File:line | Finding | Outcome |
|---|---|---|---|---|
| 1 | Nit | README.md:364 |
The docs say the button "returns to rest" on rejection, which is false when the caller drives the button with isActionLoading: the prop keeps it pending whatever the promise did. |
fixed c22a40a |
| 2 | Nit | src/components/DeleteConfirmModal/DeleteConfirmModal.test.tsx:85 |
The new rejection test mocks console.error but never asserts it was called, so the documented "reported through devError" behavior is unverified on the DeleteConfirmModal path that the changelog claims covers it. |
fixed c22a40a |
| 3 | Nit | src/components/Modal/Modal.test.tsx:913 |
The containment guard listens only for a window error event, while an escaped rejection can also surface as unhandledrejection; with only the former observed the assertion cannot detect the regression it names on a runner that reports rejections that way. |
fixed c22a40a |
| 4 | Important | src/components/Modal/Modal.test.tsx:993 |
The new isActionLoading test never invokes onAction: rendering with the prop true makes the Astryx Button busy-only, so user.click returns at handleClick without calling the action and the captured resolve stays the initial no-op. The test would still pass if isActionLoading stopped overriding the settled-promise state, which is the behavior its title and the changelog claim it covers. |
fixed c22a40a |
Security review: not re-run (round 2)
Posted inline: 4 · already inline from this round: 0 · table only (outside the diff): 0 · repeats of an earlier round dropped: 0 · Nits over the cap of 3 dropped: 1 · not posted (no file:line, or style-only): 0
Round 1 — 1f495b4
| # | Tag | File:line | Finding | Outcome |
|---|---|---|---|---|
| 1 | Nit | CHANGELOG.md:27 |
The changelog says tests cover resolve, reject and isActionLoading "on both components", but DeleteConfirmModal has no rejection test and no isActionLoading case. |
fixed d6259d9 |
| 2 | Nit | src/components/Modal/Modal.test.tsx:876 |
The rejection test's assertions (aria-busy cleared, onOpenChange not called) also hold without the fix, because Astryx Button clears pending in its own finally; it only fails on the old code because Vitest fails on React's globally reported error. It does not encode the containment it guards, so a runner or config that ignores reported errors would let the bug return untested. |
fixed d6259d9 |
| 3 | Nit | src/components/Modal/Modal.test.tsx:910 |
The isActionLoading test drops the prop before clicking, so it never checks the combined state the contract describes (busy while either the prop is true or a promise is pending); a regression that cancels a still-true isActionLoading when the promise settles would pass. |
fixed d6259d9 |
| 4 | Important | src/components/Modal/Modal.tsx:36 |
The @example above the new contract still shows a bare await in onAction, and so do DeleteConfirmModal's example and the README. A developer copying them now gets a failed action swallowed silently: the new JSDoc says the caller reports the error but never shows how, and the README's onAction paragraph says nothing about a rejection. (outside the diff — not inline) |
fixed d6259d9 |
| 5 | Pre-existing | src/components/Modal/Modal.tsx:519 |
Only this call site guards its clickAction; ConfirmPopover.tsx:158 and DataGridExportModal.tsx:210 (and any future one) still await a caller's promise bare, so they keep producing the same uncaught error this PR removes from Modal. |
needs-human |
| 6 | Important | src/components/Modal/Modal.tsx:522 |
The new catch discards a rejected onAction with no log and no telemetry, so a failed action becomes completely invisible: the spinner stops, the modal stays open with no message, and nothing reaches error reporting. devError from @astryxdesign/core/utils exists for exactly this (it reports a thrown callback in production too). The comment beside the catch also misstates the failure: the rejection is reported as a global error event out of React's transition, and the button clears its own pending state in a finally, so the catch suppresses the report rather than repairing the pending state. |
fixed d6259d9 |
Security review: 0 findings
Posted inline: 5 · already inline from this round: 0 · table only (outside the diff): 1 · repeats of an earlier round dropped: 0 · Nits over the cap of 3 dropped: 1 · not posted (no file:line, or style-only): 0
Stop catching a rejected onAction: the button's transition drops the promise it starts, so the rejection has no caller and reaches React as an uncaught error. Catching it only turned that into a console line. Document the contract in the onAction JSDoc of Modal and DeleteConfirmModal and in the README, and cover the pending state, isActionLoading and the repeated-click dedupe with tests.
Revert the experiment that let a rejected onAction escape its clickAction. React chains the transition promise into the finished state and rethrows the rejection during the render that would clear the pending state: a probe against React 19.3.1 shows the button left aria-busy and disabled, with the tree unmounted when nothing catches the render error. Catching it keeps the modal open and reports the failure through devError; a caller that wants its own message catches it in onAction.
The changelog said the transition drops the promise and the rejection reached no one; the real pre-fix failure is React rethrowing it during render. The component JSDoc now also says a caller-set isActionLoading still keeps the button pending after the rejection.
Resolves #192
Summary
ModalandDeleteConfirmModalhold the action button pending while a promise returned fromonActionis in flight: the generated action button'sclickActionawaits the result (src/components/Modal/Modal.tsx). That part already works. The rejection path is what this PR adds.Modal.tsx: the action button'sclickActioncatches a rejectedonAction. This is not swallowing it quietly: a rejection left uncaught is not propagated to a caller. AstryxButtonrunsclickActioninsidestartTransitionand chains the returned promise into the transition's finished state, so React rethrows the rejection during the render that would clear the pending state. Verified with a probe against React 19.3.1: the button staysaria-busyand disabled, and with no error boundary the subtree is unmounted — the modal disappears instead of staying open. Catching keeps the transition able to finish, so the pending state clears and the modal stays open, and the failure is reported throughdevError(the same channel Astryx uses for a plugin that throws), which reaches error telemetry. A caller that needs its own message catches it inonAction.Modal.tsx/DeleteConfirmModal.tsx: theonActionJSDoc on both components states this contract, and the README says the same.onActionstays() => unknown. Narrowing it to() => void | Promise<void>would reject a handler that returns a value (e.g.() => list.push(item)orasync () => 3), a breaking change under CONTRIBUTING's versioning table; the JSDoc carries the promise contract instead.Modal: resolve clears the pending state (existing), reject clears it and leaves the modal open,isActionLoadingstill shows the pending state on its own, and repeated clicks while pending callonActiononce.DeleteConfirmModal: a pending promise shows the loading state, and repeated clicks dedupe.[Unreleased]Fixed entry.Verification
pnpm run verifypasses (2576 tests passed, 16 skipped).Risk tier: High —
src/components/DeleteConfirmModal/DeleteConfirmModal.test.tsx,src/components/DeleteConfirmModal/DeleteConfirmModal.tsxSuggested human approvals: 2 (branch protection decides)