[signals] createOptimistic + For: a row moved by a guess renders with no text while later guesses and held writes are out
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 22/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, typescript
- Lĩnh vực
- frontend
Hướng nghiên cứu
Start from the reproduction test in the issue, which uses For over createOptimistic and calls render from ../src/index.js. Run it and check which step first leaves the row's {r.id} empty while the <li> is still in the DOM. Done means the held-state assertion passes (<li>2</li> present) without changing the settled result.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
On main (signals unchanged since 30e7805eb), a For over createOptimistic(() => truth()) mounts a row whose contents stay empty. The row is moved by a guess (a new object for the same id). While its change is held, two more things happen: other actions' truth writes land and are held too, and a later guess adds another row. The row's <li> is in the DOM but {r.id} never renders. When every action lands, the list settles right.
The guess layer holds [-1, 2', 4], and list().length is 3, so a heading over the same list counts 3 while only 2 rows show any text. We found this through a board app built on this shape. The fuzz reported a column heading that counted more cards than it showed.
Each step is needed. If you skip the remove, the add's truth write, or the move's truth write, the row renders.
/**
* @jsxImportSource @solidjs/web
* @vitest-environment jsdom
*/
import { test, expect } from "vitest";
import { For, Loading, action, createSignal, createOptimistic, flush } 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 moved by a guess renders blank once later guesses and held writes pile on", async () => {
const asks: any[] = [];
const ask = (k: string) => new Promise<any>(res => asks.push({ k, res }));
const land = (k: string, v: any) => asks.splice(asks.findIndex(a => a.k === k), 1)[0].res(v);
const [truth, setTruth] = createSignal<C[]>(async () => await ask("list"));
const [list, guess] = createOptimistic(() => truth());
const toEnd = action(function* (c: C) {
guess(rs => [...rs.filter(x => x.id != c.id), c]);
yield ask(`move:${c.id}`);
setTruth(rs => [...rs.filter(x => x.id != c.id), c]);
});
const remove = action(function* (id: number) {
guess(rs => rs.filter(x => x.id != id));
yield ask(`rm:${id}`);
setTruth(rs => rs.filter(x => x.id != id));
});
const add = action(function* (tmp: number) {
guess(rs => [...rs, { id: tmp }]);
const r = yield ask("add");
setTruth(rs => [...rs.filter(x => x.id != tmp), { id: r.id }]);
});
const c = document.body.appendChild(document.createElement("div"));
render(() => <Loading fallback="L"><ul><For each={list()}>{r => <li>{r.id}</li>}</For></ul></Loading>, c);
const steps = [
() => land("list", [{ id: 1 }, { id: 2 }]),
() => add(-1), // guess [1, 2, -1]
() => toEnd({ id: 2 }), // guess [1, -1, 2'] (2' a new object)
() => remove(1), // guess [-1, 2']
() => land("add", { id: 6 }), // add's truth write, held: its change is entangled with the others
() => land("move:2", true), // move's truth write, held
() => toEnd({ id: 4 }), // guess [-1, 2', 4]
];
await tick();
for (let i = 0; i < steps.length; i++) { steps[i](); await tick(); }
const held = c.innerHTML;
land("rm:1", true); await tick(); land("move:4", true); await tick();
expect(held).toBe("<ul><li>-1</li><li>2</li><li>4</li></ul>"); // actual: <ul><li>-1</li><li></li><li>4</li></ul>
expect(c.innerHTML).toBe("<ul><li>6</li><li>2</li><li>4</li></ul>"); // passes: it settles right
});
It looks related to #4831 and #4998 (blank rows under For, both closed), but this one is the signal form of createOptimistic, with no projection and no failed re-ask.
- Ngôn ngữ chính
- TypeScript
- Star
- 37k
- Fork
- 1.2k
- Merge trung bình
- 8 giờ 43 phút
- Pull request đã merge (30 ngày)
- 365
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của solidjs/solid
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 38/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[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 handlesCó thể đã có người làm @MilindChatrabhuji đã nhận 2 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của solidjs/solid
Issue tương tự
-
agentscan:mixed-signals pending triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
vueuse/vueuse#5737 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 9 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Marker-Inc-Korea/AutoRAG#2288 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Resources: New templates of Guangzhou Metro Line 13Có thể đã có người làm @rmt-svc đã nhận hôm nay. Đang mởresources
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 76/100
railmapgen/rmg-templates#2730 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
web
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày