Skip to content

Commit c2dd436

Browse files
authored
fix(input-time-zone): prevent items from being deselected (#7661)
**Related Issue:** #7530 ## Summary Leverages `combobox`'s new `single-persist` mode to avoid an error caused by deselecting an item.
1 parent c85b958 commit c2dd436

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

packages/calcite-components/src/components/input-time-zone/input-time-zone.e2e.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,21 @@ describe("calcite-input-time-zone", () => {
103103

104104
expect(await timeZoneItem.getProperty("textLabel")).toMatch("GMT-6");
105105
});
106+
107+
it("does not allow users to deselect a timezone offset", async () => {
108+
const page = await newE2EPage();
109+
await page.emulateTimezone("America/Los_Angeles");
110+
await page.setContent(html`<calcite-input-time-zone value="-360" open></calcite-input-time-zone>`);
111+
await page.waitForChanges();
112+
113+
let selectedTimeZoneItem = await page.find("calcite-input-time-zone >>> calcite-combobox-item[selected]");
114+
await selectedTimeZoneItem.click();
115+
await page.waitForChanges();
116+
117+
selectedTimeZoneItem = await page.find("calcite-input-time-zone >>> calcite-combobox-item[selected]");
118+
const input = await page.find("calcite-input-time-zone");
119+
120+
expect(await input.getProperty("value")).toBe("-360");
121+
expect(await selectedTimeZoneItem.getProperty("textLabel")).toMatch("GMT-6");
122+
});
106123
});

packages/calcite-components/src/components/input-time-zone/input-time-zone.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,6 @@ export class InputTimeZone
138138
*/
139139
@Prop({ mutable: true }) value: string;
140140

141-
@Watch("value")
142-
valueWatcher(value: string): void {
143-
if (this.comboboxEl && this.comboboxEl.value !== value) {
144-
this.comboboxEl.value = value;
145-
}
146-
}
147-
148141
//--------------------------------------------------------------------------
149142
//
150143
// Public Methods
@@ -316,7 +309,7 @@ export class InputTimeZone
316309
open={this.open}
317310
overlayPositioning={this.overlayPositioning}
318311
scale={this.scale}
319-
selectionMode="single"
312+
selectionMode="single-persist"
320313
// eslint-disable-next-line react/jsx-sort-props -- ref should be last so node attrs/props are in sync (see https://github.com/Esri/calcite-design-system/pull/6530)
321314
ref={this.setComboboxRef}
322315
>

0 commit comments

Comments
 (0)