Skip to content

Commit 7665551

Browse files
committed
Added logic to getFilterHeaderText
1 parent bce37b1 commit 7665551

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

packages/filter/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@equinor/workspace-filter",
3-
"version": "4.0.8",
3+
"version": "4.0.9",
44
"type": "module",
55
"sideEffects": false,
66
"license": "MIT",

packages/filter/src/lib/utils/getFilterHeaderText.tsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,24 @@ export function getFilterHeaderText(
66
name: string,
77
checkedValues: string[]
88
): string | JSX.Element {
9-
if (isAllChecked || checkedValues.length === 0) return <StyledNormalText>{name}</StyledNormalText>;
9+
const selectedCount = checkedValues.length;
1010

11-
return (
12-
<div style={{ color: tokens.colors.interactive.primary__resting.hex }}>
13-
{checkedValues.length - 1 > 0
14-
? `${checkedValues[0] ?? '(Blank)'}(+${checkedValues.length - 1})`
15-
: `${checkedValues[0]}`}{' '}
16-
</div>
17-
);
11+
const hasBlank = checkedValues.includes('(Blank)');
12+
const nonBlankCount = hasBlank ? selectedCount - 1 : selectedCount;
13+
14+
if (hasBlank && nonBlankCount > 0) {
15+
return <StyledNormalText>{`${name} (Blank) (+${nonBlankCount})`}</StyledNormalText>;
16+
}
17+
18+
if (selectedCount === 1 && hasBlank) {
19+
return <StyledNormalText>{`${name} (Blank)`}</StyledNormalText>;
20+
}
21+
22+
const displayText = selectedCount > 0 ? `${name} (+${selectedCount})` : name;
23+
24+
if (isAllChecked || selectedCount === 0) {
25+
return <StyledNormalText>{displayText}</StyledNormalText>;
26+
}
27+
28+
return <div style={{ color: tokens.colors.interactive.primary__resting.hex }}>{displayText}</div>;
1829
}

packages/workspace-fusion/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@equinor/workspace-fusion",
3-
"version": "9.0.22",
3+
"version": "9.0.23",
44
"type": "module",
55
"sideEffects": false,
66
"license": "MIT",

0 commit comments

Comments
 (0)