Skip to content
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 @@ -1421,6 +1421,16 @@ describe("calcite-combobox", () => {
</calcite-combobox>
`,
},
{
selectionMode: "single-persist",
html: html`
<calcite-combobox selection-mode="single-persist">
<calcite-combobox-item selected id="one" value="one" text-label="one"></calcite-combobox-item>
<calcite-combobox-item id="two" value="two" text-label="two"></calcite-combobox-item>
<calcite-combobox-item id="three" value="three" text-label="three"></calcite-combobox-item>
</calcite-combobox>
`,
},
{
selectionMode: "multiple",
html: html`
Expand All @@ -1446,15 +1456,25 @@ describe("calcite-combobox", () => {

describe("via mouse", () => {
testCases.forEach((testCase) => {
it(`clears the value in ${testCase.selectionMode}-selection mode`, () =>
assertValueClearing(testCase.html, "mouse", "clear"));
if (testCase.selectionMode === "single-persist") {
it(`does not clear the value in ${testCase.selectionMode}-selection mode`, () =>
assertValueClearing(testCase.html, "mouse", "no-clear"));
} else {
it(`clears the value in ${testCase.selectionMode}-selection mode`, () =>
assertValueClearing(testCase.html, "mouse", "clear"));
}
});
});

describe("via keyboard", () => {
testCases.forEach((testCase) => {
it(`clears the value in ${testCase.selectionMode}-selection mode`, () =>
assertValueClearing(testCase.html, "keyboard", "clear"));
if (testCase.selectionMode === "single-persist") {
it(`does not clear the value in ${testCase.selectionMode}-selection mode`, () =>
assertValueClearing(testCase.html, "mouse", "no-clear"));
} else {
it(`clears the value in ${testCase.selectionMode}-selection mode`, () =>
assertValueClearing(testCase.html, "keyboard", "clear"));
}
});
});
});
Expand All @@ -1471,6 +1491,16 @@ describe("calcite-combobox", () => {
</calcite-combobox>
`,
},
{
selectionMode: "single-persist",
html: html`
<calcite-combobox clear-disabled selection-mode="single-persist">
<calcite-combobox-item selected id="one" value="one" text-label="one"></calcite-combobox-item>
<calcite-combobox-item id="two" value="two" text-label="two"></calcite-combobox-item>
<calcite-combobox-item id="three" value="three" text-label="three"></calcite-combobox-item>
</calcite-combobox>
`,
},
{
selectionMode: "multiple",
html: html`
Expand All @@ -1496,14 +1526,14 @@ describe("calcite-combobox", () => {

describe("via mouse", () => {
testCases.forEach((testCase) => {
it(`clears the value in ${testCase.selectionMode}-selection mode`, () =>
it(`does not clears the value in ${testCase.selectionMode}-selection mode`, () =>
assertValueClearing(testCase.html, "mouse", "no-clear"));
});
});

describe("via keyboard", () => {
testCases.forEach((testCase) => {
it(`clears the value in ${testCase.selectionMode}-selection mode`, () =>
it(`does not clears the value in ${testCase.selectionMode}-selection mode`, () =>
assertValueClearing(testCase.html, "keyboard", "no-clear"));
});
});
Expand Down
13 changes: 12 additions & 1 deletion packages/calcite-components/src/components/combobox/combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,10 @@ export class Combobox
this.refreshSelectionDisplay();
}

async load(): Promise<void> {
this.handleSelectionModeWarning();
Comment thread
DitwanP marked this conversation as resolved.
}

loaded(): void {
afterConnectDefaultValueSet(this, this.getValue());
connectFloatingUI(this);
Expand Down Expand Up @@ -1546,6 +1550,12 @@ export class Combobox
);
}

private handleSelectionModeWarning(): void {
if (this.selectionMode === "single-persist" && this.clearDisabled) {
console.warn(`clearDisabled is ignored when selection-mode is set to "single-persist"`);
}
}

//#endregion

//#region Rendering
Expand Down Expand Up @@ -1901,7 +1911,8 @@ export class Combobox
const allSelectionDisplay = selectionDisplay === "all";
const singleSelectionDisplay = selectionDisplay === "single";
const fitSelectionDisplay = !singleSelectionMode && selectionDisplay === "fit";
const isClearable = !this.clearDisabled && this.value?.length > 0;
const isClearable =
!this.clearDisabled && this.selectionMode !== "single-persist" && !!this.value?.length;

return (
<InteractiveContainer disabled={this.disabled}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import { getCity, toUserFriendlyName } from "./utils";
*/

describe("calcite-input-time-zone", () => {
mockConsole();

type TestTimeZoneItem = {
name: string;
offset: number;
Expand Down Expand Up @@ -129,8 +131,6 @@ describe("calcite-input-time-zone", () => {
});

describe("translation support", () => {
mockConsole();

t9n(simpleTestProvider);
});

Expand Down
Loading