From 923057049eab2662c21d6ff8c8e456f7ee449dd4 Mon Sep 17 00:00:00 2001 From: levigoldberg <129314393+levigoldberg@users.noreply.github.com> Date: Mon, 29 Jul 2024 10:25:23 +0200 Subject: [PATCH 1/4] Change broken selection in enable_button_after parameter The button class was not being selected correctly resulting in a broken enable_button_after parameter --- packages/plugin-html-button-response/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/plugin-html-button-response/src/index.ts b/packages/plugin-html-button-response/src/index.ts index 81b3dda8fb..a43d29b767 100644 --- a/packages/plugin-html-button-response/src/index.ts +++ b/packages/plugin-html-button-response/src/index.ts @@ -201,12 +201,12 @@ class HtmlButtonResponsePlugin implements JsPsychPlugin { // disable all the buttons and set a timeout that enables them after a specified delay if timing is set if (trial.enable_button_after > 0) { - var btns = document.querySelectorAll(".jspsych-html-button-response-button button"); + var btns = document.querySelectorAll("#jspsych-html-button-response-btngroup button"); for (var i = 0; i < btns.length; i++) { btns[i].setAttribute("disabled", "disabled"); } this.jsPsych.pluginAPI.setTimeout(() => { - var btns = document.querySelectorAll(".jspsych-html-button-response-button button"); + var btns = document.querySelectorAll("#jspsych-html-button-response-btngroup button"); for (var i = 0; i < btns.length; i++) { btns[i].removeAttribute("disabled"); } From cb0d13e0f38f88b1d8d8f5b43be854d6a70147f1 Mon Sep 17 00:00:00 2001 From: jade <101148768+jadeddelta@users.noreply.github.com> Date: Tue, 29 Oct 2024 23:49:00 -0400 Subject: [PATCH 2/4] add changeset --- .changeset/many-dogs-shave.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/many-dogs-shave.md diff --git a/.changeset/many-dogs-shave.md b/.changeset/many-dogs-shave.md new file mode 100644 index 0000000000..8fce66f522 --- /dev/null +++ b/.changeset/many-dogs-shave.md @@ -0,0 +1,5 @@ +--- +"@jspsych/plugin-html-button-response": patch +--- + +Change broken selection in enable_button_after parameter From fe53143d8acd194720d5f3ae5514b916a6eb59e8 Mon Sep 17 00:00:00 2001 From: jade <101148768+jadeddelta@users.noreply.github.com> Date: Mon, 4 Nov 2024 18:49:15 -0500 Subject: [PATCH 3/4] fix test cases --- packages/plugin-html-button-response/src/index.spec.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/plugin-html-button-response/src/index.spec.ts b/packages/plugin-html-button-response/src/index.spec.ts index 2dd527bfe7..65cd2c0c2f 100644 --- a/packages/plugin-html-button-response/src/index.spec.ts +++ b/packages/plugin-html-button-response/src/index.spec.ts @@ -4,6 +4,10 @@ import htmlButtonResponse from "."; jest.useFakeTimers(); +beforeEach(() => { + document.body.innerHTML = ""; +}); + describe("html-button-response", () => { it("displays html stimulus and buttons", async () => { const { getHTML } = await startTimeline([ @@ -151,7 +155,8 @@ describe("html-button-response", () => { }, ]); - const btns = document.querySelectorAll(".jspsych-html-button-response-button button"); + const btns = document.querySelectorAll("div#jspsych-html-button-response-btngroup button"); + expect(btns.length).toBeGreaterThan(0); for (let i = 0; i < btns.length; i++) { expect(btns[i].getAttribute("disabled")).toBe("disabled"); From dd3caab64f2f68ffcb97ec59993c5daa645e818b Mon Sep 17 00:00:00 2001 From: jade <101148768+jadeddelta@users.noreply.github.com> Date: Sun, 1 Dec 2024 23:40:44 -0500 Subject: [PATCH 4/4] remove redundant clear of dom on test finish --- packages/plugin-html-button-response/src/index.spec.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/plugin-html-button-response/src/index.spec.ts b/packages/plugin-html-button-response/src/index.spec.ts index 65cd2c0c2f..c3ff907780 100644 --- a/packages/plugin-html-button-response/src/index.spec.ts +++ b/packages/plugin-html-button-response/src/index.spec.ts @@ -4,10 +4,6 @@ import htmlButtonResponse from "."; jest.useFakeTimers(); -beforeEach(() => { - document.body.innerHTML = ""; -}); - describe("html-button-response", () => { it("displays html stimulus and buttons", async () => { const { getHTML } = await startTimeline([