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
4 changes: 2 additions & 2 deletions packages/components/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@labkey/components",
"version": "7.45.6",
"version": "7.45.7",
"description": "Components, models, actions, and utility functions for LabKey applications and pages",
"sideEffects": false,
"files": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1812,4 +1812,40 @@ describe('resolveValueDescriptors', () => {
resolveValueDescriptors(floatLookupCol, {}, {}, 'cellKey', { value: 1, displayValue: 'Sample 1' })
).toStrictEqual([{ display: 'Sample 1', raw: 1 }]);
});

// Issue 1288: read-only columns (e.g. ancestor identifying fields) should keep the server's displayValue
// rather than re-deriving the display from the raw value.
test('readOnly columns use displayValue and skip reformatting', () => {
// Decimal: editable columns ignore displayValue in favor of the raw value (Issue 53934), but a
// read-only column should surface the server-formatted displayValue.
const floatCol = new QueryColumn({ fieldKey: 'col1', name: 'col1', jsonType: 'float' });
const readOnlyFloatCol = new QueryColumn({ fieldKey: 'col1', name: 'col1', jsonType: 'float', readOnly: true });
expect(
resolveValueDescriptors(floatCol, {}, {}, 'cellKey', { value: 1.005, displayValue: 1.01 })
).toStrictEqual([{ display: 1.005, raw: 1.005 }]);
expect(
resolveValueDescriptors(readOnlyFloatCol, {}, {}, 'cellKey', { value: 1.005, displayValue: 1.01 })
).toStrictEqual([{ display: 1.01, raw: 1.005 }]);

// DateTime: a read-only column returns the server displayValue verbatim instead of running the raw
// value through the date formatter (which, for this column's format, would produce '2023-Feb-14 06:30').
const readOnlyDateTimeCol = new QueryColumn({
fieldKey: 'col1',
name: 'col1',
rangeURI: DATETIME_RANGE_URI,
format: 'yyyy-MMM-dd HH:mm',
readOnly: true,
});
expect(
resolveValueDescriptors(readOnlyDateTimeCol, {}, {}, 'cellKey', {
value: '2023-02-14 06:30:00.000',
displayValue: '2023-02-14 06:30',
})
).toStrictEqual([{ display: '2023-02-14 06:30', raw: '2023-02-14 06:30:00.000' }]);

// Read-only datetime with no displayValue falls back to the raw value (not reformatted).
expect(
resolveValueDescriptors(readOnlyDateTimeCol, {}, {}, 'cellKey', { value: '2023-02-14 06:30:00.000' })
).toStrictEqual([{ display: '2023-02-14 06:30:00.000', raw: '2023-02-14 06:30:00.000' }]);
});
});
10 changes: 6 additions & 4 deletions packages/components/src/internal/components/editable/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,12 @@ export function resolveValueDescriptors(
}

let display = value?.displayValue ?? raw;
if (col.isTimeOrDateTimeColumn) {
display = getDateTimeDisplayValueFromStr(raw, col);
} else if (!col.isLookup() && col.isDecimalJsonType) {
display = raw; // Issue 53934: don't use displayValue for numeric columns
if (!col.readOnly) {
if (col.isTimeOrDateTimeColumn) {
display = getDateTimeDisplayValueFromStr(raw, col);
} else if (!col.isLookup() && col.isDecimalJsonType) {
display = raw; // Issue 53934: don't use displayValue for numeric columns
}
}

return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,10 @@ describe('getFieldDisplayValue', () => {
test('handles single-element array', () => {
expect(getFieldDisplayValue({ value: ['only'] })).toBe('only');
});

test('returns empty string when fieldData is missing', () => {
expect(getFieldDisplayValue(undefined)).toBe('');
expect(getFieldDisplayValue(null)).toBe('');
expect(getFieldDisplayValue('')).toBe('');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,7 @@ export function getSingleSampleTypeQueryInfo(sampleIds: number[] | string[]): Pr

// GitHub Issue 928: Spaces not shown between text choices in identifying fields in editable grid
export function getFieldDisplayValue(fieldData: any): string {
if (!fieldData) return '';
const val = fieldData.formattedValue ?? fieldData.displayValue ?? fieldData.value;
if (Array.isArray(val)) return val.join(', ');
return val;
Expand Down