@celestia-island/hikari 0.55.187 → 0.55.188
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -69,6 +69,32 @@ describe("HkRowActions", () => {
|
|
|
69
69
|
expect(btn.getAttribute("aria-expanded")).toBe("false");
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
+
it("menu mode: a leaf row click emits select with the item and closes", async () => {
|
|
73
|
+
const items: HkMenuItem[] = [
|
|
74
|
+
{ key: "edit", label: "Edit" },
|
|
75
|
+
{ key: "delete", label: "Delete", danger: true },
|
|
76
|
+
];
|
|
77
|
+
const selected: HkMenuItem[] = [];
|
|
78
|
+
const c = mount(h(HkRowActions, { items, onSelect: (item: HkMenuItem) => selected.push(item) }));
|
|
79
|
+
const btn = c.querySelector("button.hk-icon-button") as HTMLButtonElement;
|
|
80
|
+
btn.click();
|
|
81
|
+
await Promise.resolve();
|
|
82
|
+
await Promise.resolve();
|
|
83
|
+
// The menu rows render through HkSelectPanel's teleported popout.
|
|
84
|
+
const row = Array.from(
|
|
85
|
+
document.body.querySelectorAll<HTMLButtonElement>("button.hk-menu-row"),
|
|
86
|
+
).find((b) => b.textContent?.trim() === "Edit");
|
|
87
|
+
expect(row).toBeTruthy();
|
|
88
|
+
row!.click();
|
|
89
|
+
await Promise.resolve();
|
|
90
|
+
await Promise.resolve();
|
|
91
|
+
expect(selected).toHaveLength(1);
|
|
92
|
+
expect(selected[0]!.key).toBe("edit");
|
|
93
|
+
expect(selected[0]!.label).toBe("Edit");
|
|
94
|
+
// The leaf path closed the popup inside HkMenu; aria follows.
|
|
95
|
+
expect(btn.getAttribute("aria-expanded")).toBe("false");
|
|
96
|
+
});
|
|
97
|
+
|
|
72
98
|
it("stops the click from reaching clickable ancestors", () => {
|
|
73
99
|
const outer = vi.fn();
|
|
74
100
|
const c = mount(
|
|
@@ -89,7 +89,11 @@ export default defineComponent({
|
|
|
89
89
|
emit("open", openerEl() ?? (e.currentTarget as HTMLElement));
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
function onSelect(item: HkMenuItem) {
|
|
92
|
+
function onSelect(key: string, item: HkMenuItem) {
|
|
93
|
+
// HkMenu's select emit is (key, item) — the key FIRST, matching the
|
|
94
|
+
// HkMenu contract; the consumer-facing select carries the item.
|
|
95
|
+
// The popup is already closed by HkMenu's leaf path (closeAll runs
|
|
96
|
+
// before the emit), so `open` only needs to follow on paper.
|
|
93
97
|
open.value = false;
|
|
94
98
|
emit("select", item);
|
|
95
99
|
}
|