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(input-time-zone): add max-items support #7705

Merged
merged 3 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe("calcite-input-time-zone", () => {
describe("reflects", () => {
reflects("calcite-input-time-zone", [
{ propertyName: "disabled", value: true },
{ propertyName: "maxItems", value: 0 },
{ propertyName: "open", value: true },
{ propertyName: "scale", value: "m" },
{ propertyName: "overlayPositioning", value: "absolute" },
Expand All @@ -51,6 +52,7 @@ describe("calcite-input-time-zone", () => {
describe("defaults", () => {
defaults("calcite-input-time-zone", [
{ propertyName: "disabled", defaultValue: false },
{ propertyName: "maxItems", defaultValue: 0 },
{ propertyName: "messageOverrides", defaultValue: undefined },
{ propertyName: "open", defaultValue: false },
{ propertyName: "overlayPositioning", defaultValue: "absolute" },
Expand Down Expand Up @@ -120,4 +122,14 @@ describe("calcite-input-time-zone", () => {
expect(await input.getProperty("value")).toBe("-360");
expect(await selectedTimeZoneItem.getProperty("textLabel")).toMatch("GMT-6");
});

it("supports setting maxItems to display", async () => {
const page = await newE2EPage();
await page.setContent(html`<calcite-input-time-zone max-items="7"></calcite-input-time-zone>`);

const internalCombobox = await page.find("calcite-input-time-zone >>> calcite-combobox");

// we assume maxItems works properly on combobox
expect(await internalCombobox.getProperty("maxItems")).toBe(7);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ export class InputTimeZone
*/
@Prop({ reflect: true }) form: string;

/** Specifies the maximum number of input time zone options to display before displaying a scrollbar. */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT about the following for doc consistency?:

Specifies the component's maximum number of options to display before displaying a scrollbar.

@Prop({ reflect: true }) maxItems = 0;

/**
* Made into a prop for testing purposes only
*
Expand Down Expand Up @@ -301,6 +304,7 @@ export class InputTimeZone
disabled={this.disabled}
label={this.messages.chooseTimeZone}
lang={this.effectiveLocale}
maxItems={this.maxItems}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how will this prop be used? What happens when more items exist than the max allowed items? Will items simply not render or will the customer receive some kind of warning/alert that they have exceeded the max items? Will this be included in a separate PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good questions. To summarize, this prop basically defines the amount of items displayed before a scrollbar is displayed.

onCalciteComboboxBeforeClose={this.onComboboxBeforeClose}
onCalciteComboboxBeforeOpen={this.onComboboxBeforeOpen}
onCalciteComboboxChange={this.onComboboxChange}
Expand Down