From db5aaee501acc9ff307047c0c867d91796b3497d Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Sat, 22 Mar 2025 08:45:44 -0700 Subject: [PATCH] fix(radio-button): forward `focus`, `blur` events --- src/RadioButton/RadioButton.svelte | 2 ++ tests/RadioButton/RadioButton.test.svelte | 6 ++++++ tests/RadioButton/RadioButton.test.ts | 3 +-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/RadioButton/RadioButton.svelte b/src/RadioButton/RadioButton.svelte index 6fecf17e..3ce9aa22 100644 --- a/src/RadioButton/RadioButton.svelte +++ b/src/RadioButton/RadioButton.svelte @@ -71,6 +71,8 @@ required={$groupRequired ?? required} {value} class:bx--radio-button={true} + on:focus + on:blur on:change on:change={() => { if (update) { diff --git a/tests/RadioButton/RadioButton.test.svelte b/tests/RadioButton/RadioButton.test.svelte index 166c4b42..59282887 100644 --- a/tests/RadioButton/RadioButton.test.svelte +++ b/tests/RadioButton/RadioButton.test.svelte @@ -26,6 +26,12 @@ {id} {name} {ref} + on:focus={() => { + console.log("focus"); + }} + on:blur={() => { + console.log("blur"); + }} on:change={() => { console.log("change"); }} diff --git a/tests/RadioButton/RadioButton.test.ts b/tests/RadioButton/RadioButton.test.ts index 6103c8d8..3b321c57 100644 --- a/tests/RadioButton/RadioButton.test.ts +++ b/tests/RadioButton/RadioButton.test.ts @@ -91,8 +91,7 @@ describe("RadioButton", () => { expect(consoleLog).toHaveBeenCalledWith("change"); }); - // TODO(bug): forward focus/blur events. - it.skip("should handle focus and blur events", async () => { + it("should handle focus and blur events", async () => { const consoleLog = vi.spyOn(console, "log"); render(RadioButton);