[signals] A row mounted while a guess is held misses a later guess in an attribute, though the memo it reads shows it
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 45/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- javascript, typescript
- Bereich
- frontend
Rechercherichtung
Start with the supplied Vitest/jsdom reproduction and trace how createMemo, Show, and For propagate updates to the disabled attribute when rows mount while an optimistic guess is held. The issue names no implementation or test file paths, so locate the relevant reactive update code and existing tests from those entry points. Done means the reproduction passes with both buttons reflecting full() after the later move, while retaining the second observation about To do being asked again for investigation.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
On main 30e7805eb (jsdom). Three lists, each createSignal(async) under createOptimistic, rendered in a For under Loading + Errored. A memo full = doing().length >= 3 drives disabled on the To do rows.
To do's first load fails, and its retry answers while a move is held (its answer never comes). To do's rows mount at that point. A later move guesses Doing to three cards. The Doing column shows three cards and full() returns true, but the To do rows' disabled attribute stays false.
It needs both the held earlier move and a Show when={selCard()} over a memo that reads the lists. Without either one the attribute updates.
/**
* @jsxImportSource @solidjs/web
* @vitest-environment jsdom
*/
import { test, expect } from "vitest";
import { For, Show, Loading, Errored, action, createMemo, createSignal, createOptimistic, flush, refresh } from "solid-js";
import { render } from "../src/index.js";
const tick = async () => { for (let i = 0; i < 4; i++) { await new Promise(r => setTimeout(r, 0)); flush(); } };
type C = { id: number };
test("a row mounted while a guess is held keeps a stale attribute when a later guess changes the memo it reads", async () => {
const asks: any[] = [];
const ask = (k: string) => new Promise<any>((res, rej) => asks.push({ k, res, rej }));
const find = (k: string) => asks.splice(asks.findIndex(a => a.k === k), 1)[0];
const list = (k: string) => {
const [truth] = createSignal<C[]>(async () => await ask(k));
const [shown, guess] = createOptimistic(() => truth());
return { truth, shown, guess };
};
const c = document.body.appendChild(document.createElement("div"));
let api: any;
function Board() {
const todo = list("todo"), doing = list("doing"), done = list("done");
const L: any = { todo, doing, done };
const full = createMemo(() => doing.shown().length >= 3);
const [sel, setSel] = createSignal<number | null>(null);
const selCol = createMemo(() => sel() == null ? null : todo.shown().some(x => x.id === sel()) ? "todo" : doing.shown().some(x => x.id === sel()) ? "doing" : "done");
const selCard = createMemo(() => selCol() == null ? null : (L[selCol()!].shown() as C[]).find(x => x.id === sel()));
const move = action(function* (id: number, from: string, to: string, index: number) {
L[from].guess((rs: C[]) => rs.filter(x => x.id !== id));
L[to].guess((rs: C[]) => { const n = [...rs]; n.splice(index, 0, { id }); return n; });
yield ask(`move:${id}`);
refresh(L[from].truth); refresh(L[to].truth);
});
api = { todo, full, setSel, move };
const Column = (p: { col: string }) => <Loading fallback="L">
<Errored fallback={`${p.col}:E `}>
{p.col}:<For each={L[p.col].shown()}>{(r: C) => <i>{r.id}{p.col === "todo" ? <button disabled={full()}>r</button> : null}</i>}</For>{" "}
</Errored>
</Loading>;
return <>
<Column col="todo" /><Column col="doing" /><Column col="done" />
<Show when={selCard()} fallback="pick">#{sel()} in {selCol()}</Show>
</>;
}
render(() => <Board />, c);
const disabled = () => [...c.querySelectorAll("button")].map(b => b.disabled);
await tick();
find("doing").res([{ id: 3 }, { id: 4 }]); await tick();
find("todo").rej(new Error("declined")); await tick();
find("done").res([{ id: 5 }]); await tick();
api.setSel(5); await tick();
refresh(api.todo.truth); await tick(); // retry To do
api.move(5, "done", "doing", 2); await tick(); // Doing 3, 4, 5 (its answer never comes)
api.move(3, "doing", "done", 0); await tick(); // Doing 4, 5
find("todo").res([{ id: 1 }, { id: 2 }]); await tick(); // To do's rows mount now
find("move:3").res({}); await tick(); // re-asks Doing and Done (left out)
find("todo").res([{ id: 1 }, { id: 2 }]); await tick(); // To do is asked again here; answer it
expect(c.textContent).toBe("todo:1r2r doing:45 done:3 #5 in doing");
expect(disabled()).toEqual([false, false]);
api.move(3, "done", "doing", 2); await tick(); // Doing 4, 5, 3: full
expect(c.textContent).toBe("todo:1r2r doing:453 done: #5 in doing");
expect(api.full()).toBe(true);
expect(disabled()).toEqual([true, true]); // actual: [false, false]
});
Expected: once Doing shows three cards, every row's disabled={full()} reads true, the same as full(). Actual: the rows that mounted during the held move keep false. The screen then offers a To do move into a full Doing.
Two side observations: To do is asked a second time after move:3 lands, though that move refreshes only Doing and Done. The repro needs that second answer, and without the last line before the asserts it passes.
Found by an eval app (a work-in-progress limit on a three-column board) in the ReactiveScript eval.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 37k
- Forks
- 1.2k
- Ø Merge
- 8 Std. 43 Min.
- Gemergte PRs (30 T.)
- 365
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus solidjs/solid
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 88/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 38/100
Maintainer antworten meist innerhalb von 1 Tag
-
[2.0.4] Nested `<Errored>`: the outer boundary stays on an error the inner one rethrew, after the next error is one the inner one handlesEvtl. vergeben @MilindChatrabhuji hat das vor 2 Tagen übernommen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 69/100
activepieces/activepieces#17974 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
OHDSI/Data2Evidence#3777 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
bug enhancement
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
AOSSIE-Org/PictoPy#1802 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 3 Tagen
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
Termix-SSH/Plugin-Snippets#26 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
agent-reported bug from-app needs-triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
nightly-labs/openbot#20504 ·
Maintainer antworten meist innerhalb von 1 Tag