fix(presentation): show a disabled query as idle instead of empty (R3-4)
A disabled query (no data, no error, not fetching) fell through
deriveAsyncState to "empty", so AsyncSurface rendered the
"no items" copy before the query had even started.
- AsyncState.base gains "idle" for "not started / waiting on a
precondition". A completed empty result (`[]`, `""`, `null`) stays
"empty"; a real first load stays "initial-loading".
- AsyncSurface renders an optional `idle` slot for idle, else nothing
(no skeleton, no aria-busy, no empty copy, no children).
Consumer-facing: AsyncState["base"] union adds "idle" (additive);
AsyncSurface gains an optional `idle` prop. No in-repo exhaustive
switch over base needed changes.
RED (before the fix, node scripts/run-vitest.ts on the two files):
application-query-bridge > disabled query: expected 'empty' to be 'idle'
async-surface > derives base state 4 ({}): expected 'empty' to be 'idle'
async-surface > idle renders neither loading nor empty:
toBeEmptyDOMElement() received the empty-copy section
Tests 3 failed | 25 passed (pins for first load, [] and null empty passed)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
d66ae19ad0
commit
5848493580
@@ -1,6 +1,7 @@
|
||||
import type { AppFailure } from "../../contracts/errors.ts";
|
||||
|
||||
export const ASYNC_BASE_STATES = Object.freeze([
|
||||
"idle",
|
||||
"initial-loading",
|
||||
"success",
|
||||
"empty",
|
||||
@@ -91,13 +92,14 @@ export function deriveAsyncState(signals: AsyncSignals): AsyncState {
|
||||
? "initial-loading"
|
||||
: signals.failure && !hasData
|
||||
? "terminal-error"
|
||||
: empty
|
||||
: empty || signals.data === null
|
||||
? "empty"
|
||||
: hasData
|
||||
? "success"
|
||||
: // Nothing loading, failed or present (a disabled query) is not
|
||||
// a load in progress.
|
||||
"empty";
|
||||
: // Nothing loading, failed or returned yet (a disabled query
|
||||
// waiting on a precondition): not started, not a load or a
|
||||
// completed empty result.
|
||||
"idle";
|
||||
|
||||
const indicator =
|
||||
signals.hasMutationEffectUnknown && hasData
|
||||
|
||||
Reference in New Issue
Block a user