Compare commits

...
Author SHA1 Message Date
Sonarly Claude Code 0464fb7013 fix: include label identifier in record table widget view fields even if system field
https://sonarly.com/issue/18601?type=bug

When a record table widget is embedded in a dashboard for an object whose label identifier is the `id` field (a system field), the table header renders one extra duplicate column, causing all header columns to be misaligned with body columns.

Fix: Modified `filterFieldsForRecordTableViewCreation` to accept the `labelIdentifierFieldMetadataId` parameter and allow the label identifier field through even when it's a system field. This ensures that when a record table widget view is created for an object whose label identifier is `id` (a system field), the `id` field is included as a view field.

Without this fix, the `id` field was excluded from `visibleRecordFields` because `!field.isSystem` filtered it out. This caused the record table header to render a duplicate first column (since `filterOutByProperty` in `RecordTableHeaderFirstScrollableCell` was a no-op when the label identifier wasn't in the visible fields list), misaligning header columns with body columns.

The pattern matches the existing approach in `visibleRecordFieldsComponentSelector` where `isLabelIdentifier` overrides the `isActiveFieldMetadataItem` check.

Updated the single call site in `useCreateViewForRecordTableWidget` to pass `objectMetadataItem.labelIdentifierFieldMetadataId` (which was already available in scope).
2026-03-26 08:15:18 +00:00
2 changed files with 12 additions and 3 deletions
@@ -38,8 +38,11 @@ export const useCreateViewForRecordTableWidget = (pageLayoutId: string) => {
return;
}
const eligibleFields = objectMetadataItem.fields.filter(
filterFieldsForRecordTableViewCreation,
const eligibleFields = objectMetadataItem.fields.filter((field) =>
filterFieldsForRecordTableViewCreation(
field,
objectMetadataItem.labelIdentifierFieldMetadataId,
),
);
const sortedFields = eligibleFields.toSorted(
@@ -3,6 +3,12 @@ import { isHiddenSystemField } from '@/object-metadata/utils/isHiddenSystemField
export const filterFieldsForRecordTableViewCreation = (
field: FieldMetadataItem,
labelIdentifierFieldMetadataId: string,
) => {
return field.isActive && !field.isSystem && !isHiddenSystemField(field);
const isLabelIdentifier = field.id === labelIdentifierFieldMetadataId;
return (
field.isActive &&
(isLabelIdentifier || (!field.isSystem && !isHiddenSystemField(field)))
);
};