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

feat(filter): add label property #11001

Merged
merged 2 commits into from
Dec 6, 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
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ describe("calcite-filter", () => {
expect(await input.getProperty("scale")).toBe(scale);
});

it("honors label property", async () => {
const page = await newE2EPage();
const label = "hello world";
await page.setContent(`<calcite-filter label="${label}"></calcite-filter>`);

const input = await page.find(`calcite-filter >>> calcite-input`);
expect(await input.getProperty("label")).toBe(label);
});

describe("strings", () => {
it("should update the filter placeholder when a string is provided", async () => {
const page = await newE2EPage();
Expand Down
7 changes: 6 additions & 1 deletion packages/calcite-components/src/components/filter/filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ export class Filter extends LitElement implements InteractiveComponent, Loadable
*/
@property() items: object[] = [];

/**
* Specifies an accessible name for the component.
*/
@property() label: string;

/** Use this property to override individual strings used by the component. */
@property() messageOverrides?: typeof this.messages._overrides;

Expand Down Expand Up @@ -232,7 +237,7 @@ export class Filter extends LitElement implements InteractiveComponent, Loadable
clearable={true}
disabled={disabled}
icon={ICONS.search}
label={this.messages.label}
label={this.label ?? this.messages.label}
messageOverrides={{ clear: this.messages.clear }}
onKeyDown={this.keyDownHandler}
oncalciteInputInput={this.inputHandler}
Expand Down
Loading