fix(list-box): preserve typed virtual keys and add HD-09 review repros

This commit is contained in:
maoyingjie
2026-10-29 16:36:02 +08:00
parent ee37e66d37
commit ae27fb28d1
3 changed files with 137 additions and 5 deletions
+39
View File
@@ -274,3 +274,42 @@ describe("ListBox virtual row stream", () => {
expect(option.getAttribute("aria-setsize")).toBe("40");
});
});
it("review: numeric and string keys preserve local row identity on reorder", async () => {
const Stateful = defineComponent({
props: {
item: {
type: Object as PropType<{ id: string | number }>,
required: true,
},
},
setup(props) {
const born = `${typeof props.item.id}:${props.item.id}`;
return () =>
h(
ListBoxItem,
{ id: props.item.id },
() => `${typeof props.item.id}:${props.item.id}/${born}`,
);
},
});
const items = [{ id: 0 }, { id: "0" }];
const w = mount(ListBox, {
props: { items, virtualized: true, rowHeight: 50 },
slots: {
default: ({ item }: { item: { id: string | number } }) =>
h(Stateful, { item }),
},
attachTo: document.body,
});
wrappers.push(w);
await nextTick();
await nextTick();
await w.setProps({ items: [...items].reverse() });
await nextTick();
await nextTick();
expect(w.findAll('[role="option"]').map((x) => x.text())).toEqual([
"string:0/string:0",
"number:0/number:0",
]);
});