From d53c7f6df4081796667c576c8a95b0a70cd364fe Mon Sep 17 00:00:00 2001 From: Luke LaValva Date: Fri, 1 Nov 2024 15:35:49 -0700 Subject: [PATCH] fix: logic for collapse-on-select was backwards (#2315) = --- .changeset/hungry-stingrays-chew.md | 5 +++++ src/components/ebay-listbox-button/component.ts | 2 +- src/components/ebay-listbox-button/test/test.browser.js | 7 +++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .changeset/hungry-stingrays-chew.md diff --git a/.changeset/hungry-stingrays-chew.md b/.changeset/hungry-stingrays-chew.md new file mode 100644 index 000000000..85e598388 --- /dev/null +++ b/.changeset/hungry-stingrays-chew.md @@ -0,0 +1,5 @@ +--- +"@ebay/ebayui-core": patch +--- + +Fix collapseOnSelect diff --git a/src/components/ebay-listbox-button/component.ts b/src/components/ebay-listbox-button/component.ts index 261896cb4..560c78b48 100644 --- a/src/components/ebay-listbox-button/component.ts +++ b/src/components/ebay-listbox-button/component.ts @@ -52,7 +52,7 @@ class ListboxButton extends Marko.Component { } handleListboxChange(event: ChangeEvent) { - if (this.input.collapseOnSelect === false) { + if (this.input.collapseOnSelect !== false) { this._expander.expanded = false; } const selectedIndex = event.index; diff --git a/src/components/ebay-listbox-button/test/test.browser.js b/src/components/ebay-listbox-button/test/test.browser.js index d32eb09c5..33c3ffbbb 100644 --- a/src/components/ebay-listbox-button/test/test.browser.js +++ b/src/components/ebay-listbox-button/test/test.browser.js @@ -157,6 +157,13 @@ describe("given the listbox is in an expanded state", () => { .has.property("selected") .and.is.deep.equal([options[1].value]); }); + + it("then it has collapsed the listbox", () => { + expect(component.getByRole("button")).toHaveAttribute( + "aria-expanded", + "false", + ); + }); }); describe("when the down arrow key is pressed", () => {