diff --git a/packages/components/package-lock.json b/packages/components/package-lock.json index 426ba96bca..ffaf82b286 100644 --- a/packages/components/package-lock.json +++ b/packages/components/package-lock.json @@ -1,12 +1,12 @@ { "name": "@labkey/components", - "version": "7.21.1", + "version": "7.21.1-fb-checkInUnits790.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@labkey/components", - "version": "7.21.1", + "version": "7.21.1-fb-checkInUnits790.0", "license": "SEE LICENSE IN LICENSE.txt", "dependencies": { "@hello-pangea/dnd": "18.0.1", diff --git a/packages/components/package.json b/packages/components/package.json index 9f71615f15..aa0f9a52cd 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -1,6 +1,6 @@ { "name": "@labkey/components", - "version": "7.21.1", + "version": "7.21.1-fb-checkInUnits790.0", "description": "Components, models, actions, and utility functions for LabKey applications and pages", "sideEffects": false, "files": [ diff --git a/packages/components/releaseNotes/components.md b/packages/components/releaseNotes/components.md index 9bce4dd663..719b4864f2 100644 --- a/packages/components/releaseNotes/components.md +++ b/packages/components/releaseNotes/components.md @@ -1,6 +1,10 @@ # @labkey/components Components, models, actions, and utility functions for LabKey applications and pages +### version 7.21.TBD +*Released*: TBD +- GitHub Issue #790: Update areUnitsCompatible to account for different "Count" unit labels + ### version 7.21.1 *Released*: 4 March 2026 - GitHub Issue 829: Sample type with lookup to list with text primary key where the value contains a comma doesn't map to lookup diff --git a/packages/components/src/internal/util/measurement.test.ts b/packages/components/src/internal/util/measurement.test.ts index 3a5dd7b81b..f2fb898e3b 100644 --- a/packages/components/src/internal/util/measurement.test.ts +++ b/packages/components/src/internal/util/measurement.test.ts @@ -234,4 +234,13 @@ describe('areUnitsCompatible', () => { expect(areUnitsCompatible('mL', 'bogus')).toBeFalsy(); expect(areUnitsCompatible('kg', 'bogus')).toBeFalsy(); }); + + test('comparison of Count units with different labels but same kind', () => { + expect(areUnitsCompatible('count', 'count')).toBeTruthy(); + expect(areUnitsCompatible('blocks', 'blocks')).toBeTruthy(); + expect(areUnitsCompatible('boxes', 'cells')).toBeFalsy(); + expect(areUnitsCompatible('kits', 'packs')).toBeFalsy(); + expect(areUnitsCompatible('pieces', 'unit')).toBeFalsy(); + expect(areUnitsCompatible('unit', 'unit')).toBeTruthy(); + }); }); diff --git a/packages/components/src/internal/util/measurement.ts b/packages/components/src/internal/util/measurement.ts index 1807189cd2..dde5476d8f 100644 --- a/packages/components/src/internal/util/measurement.ts +++ b/packages/components/src/internal/util/measurement.ts @@ -222,7 +222,13 @@ export function areUnitsCompatible(unitAStr: string, unitBStr: string): boolean if (!unitA || !unitB) { return false; } - return unitA.kind === unitB.kind; + + // GitHub Issue #790: for "Count" kind, the specific label must also match + const matchingKinds = unitA.kind === unitB.kind; + if (matchingKinds && unitA.kind === UNITS_KIND.COUNT) { + return unitA.label === unitB.label; + } + return matchingKinds; } export function getMetricUnitOptions(metricUnit?: string, showLongLabel?: boolean): { label: string; value: string }[] {