Skip to content

Commit

Permalink
fix(combobox): updated to default filtering behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
saiponnada committed Dec 17, 2024
1 parent b8516f0 commit f876f80
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 21 deletions.
5 changes: 5 additions & 0 deletions .changeset/polite-starfishes-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ebay/ebayui-core": minor
---

fix(combobox): updated to default filtering behavior
5 changes: 5 additions & 0 deletions src/components/ebay-combobox/combobox.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ export default {
type: "boolean",
control: { type: "boolean" },
description: "Filters listbox options based on user input",
table: {
defaultValue: {
summary: "false",
},
},
},
"floating-label": {
control: { type: "text" },
Expand Down
4 changes: 2 additions & 2 deletions src/components/ebay-combobox/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default class Combobox extends Marko.Component<Input, State> {
if (this.listSelection === "automatic") {
const selected = this._getVisibleOptions()[ev.detail.toIndex];
// Set textbox value to selected, don't update state since it messes up active descendant
(this.getEl("combobox") as HTMLInputElement).value = selected.text;
(this.getEl("combobox") as HTMLInputElement).value = selected?.text;
}
}

Expand Down Expand Up @@ -350,7 +350,7 @@ export default class Combobox extends Marko.Component<Input, State> {
_getVisibleOptions() {
if (
this.autocomplete === "none" ||
(this.input.viewAllOptions ?? true)
(this.input.viewAllOptions ?? false)
) {
return [...(this.input.options ?? [])];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -721,24 +721,6 @@ exports[`combobox > renders with second item selected 1`] = `
class="combobox__listbox"
role="listbox"
>
<div
class="combobox__option"
role="option"
tabindex="-1"
>
<span>
August Campaign
</span>
</div>
<div
class="combobox__option"
role="option"
tabindex="-1"
>
<span>
4th of July Sale (paused)
</span>
</div>
<div
class="combobox__option"
role="option"
Expand Down
3 changes: 2 additions & 1 deletion src/components/ebay-combobox/test/test.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,11 @@ describe("given the combobox with 3 items", () => {
}
});

describe("given the combobox with 3 items and 2 selected", () => {
describe("given the combobox with 3 items and 2 selected and view all options", () => {
beforeEach(async () => {
component = await render(Isolated, {
value: Isolated.args.options[1].text,
viewAllOptions: true,
});
});

Expand Down

0 comments on commit f876f80

Please sign in to comment.