Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(combobox): updated to default filtering behavior #2345

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rich-coins-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ebay/ebayui-core": patch
---

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
Loading