Skip to content

Commit

Permalink
refactor(combobox): fix linting errors (#8235)
Browse files Browse the repository at this point in the history
**Related Issue:** #7912

## Summary

Fixes linting errors introduced by the PR linked above.
  • Loading branch information
benelan authored Nov 21, 2023
1 parent 726712e commit 7075db1
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions packages/calcite-components/src/components/combobox/combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ export class Combobox
(chipEl) => chipEl.closable
);

let availableHorizontalChipElSpace = Math.round(
const availableHorizontalChipElSpace = Math.round(
chipContainerElWidth -
((this.selectedHiddenChipsCount > 0 ? selectedIndicatorChipElWidth : 0) +
chipContainerElGap +
Expand Down Expand Up @@ -1373,6 +1373,7 @@ export class Combobox
scale={scale}
title={label}
value=""
// 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)
ref={setAllSelectedIndicatorChipEl}
>
{label}
Expand Down Expand Up @@ -1412,7 +1413,9 @@ export class Combobox
selectedVisibleChipsCount,
setSelectedIndicatorChipEl,
} = this;
let chipInvisible, label;
let chipInvisible: boolean;
let label: string;

if (compactSelectionDisplay) {
chipInvisible = true;
} else {
Expand All @@ -1427,14 +1430,10 @@ export class Combobox
}
label = `${selectedItemsCount} ${this.messages.selected}`;
} else if (selectionDisplay === "fit") {
if (
chipInvisible = !!(
(this.isAllSelected() && selectedVisibleChipsCount === 0) ||
selectedHiddenChipsCount === 0
) {
chipInvisible = true;
} else {
chipInvisible = false;
}
);
label =
selectedVisibleChipsCount > 0
? `+${selectedHiddenChipsCount}`
Expand All @@ -1447,10 +1446,11 @@ export class Combobox
chip: true,
[CSS.chipInvisible]: chipInvisible,
}}
ref={setSelectedIndicatorChipEl}
scale={scale}
title={label}
value=""
// 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)
ref={setSelectedIndicatorChipEl}
>
{label}
</calcite-chip>
Expand All @@ -1465,16 +1465,18 @@ export class Combobox
scale,
selectedHiddenChipsCount,
} = this;
let chipInvisible, label;
let chipInvisible: boolean;
let label: string;

if (compactSelectionDisplay) {
const selectedItemsCount = getSelectedItems().length;
if (this.isAllSelected()) {
chipInvisible = true;
} else if (selectionDisplay === "fit") {
chipInvisible = selectedHiddenChipsCount > 0 ? false : true;
chipInvisible = !(selectedHiddenChipsCount > 0);
label = `${selectedHiddenChipsCount || 0}`;
} else if (selectionDisplay === "single") {
chipInvisible = selectedItemsCount > 0 ? false : true;
chipInvisible = !(selectedItemsCount > 0);
label = `${selectedItemsCount}`;
}
} else {
Expand Down

0 comments on commit 7075db1

Please sign in to comment.