fix(fields): lookup chip resolves display name via referenced object schema, aligning with the picker (#2357)#2551
Merged
Conversation
…chema, not the autonumber-prone key heuristic (#2357) The lookup read cell (LookupCellRenderer — record header highlight + detail sections) resolved display names with the local pickRecordDisplayName heuristic, whose _number/_code suffix scan surfaced an autonumber ("0001") over the record's real name whenever the referenced object declared its title via nameField/titleFormat. The picker (LookupField) already resolved through the unified ADR-0079 resolver, so chip and picker disagreed. - LookupCellRenderer now fetches the referenced object's schema (dataSource.getObjectSchema, module-level cache shared across cells) and resolves expanded records through getRecordDisplayName with the precedence displayField → nameField/displayNameField → titleFormat → type-aware derivation; the key heuristic remains only as the no-schema fallback. - useLookupName (fetch-on-demand for bare foreign-key ids) resolves the fetched record through the same path and honours the field's explicit display_field. - @object-ui/core: NON_TITLE_TYPES now also excludes the ObjectStack spelling auto_number, so type-aware derivation can never pick an autonumber as a record title. Closes #2357
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
…357-a25c79 # Conflicts: # packages/fields/src/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #2357.
The lookup read chip (
LookupCellRenderer— record header highlight + detail sections) resolved display names with the localpickRecordDisplayNamekey heuristic, whose_number/_codesuffix scan surfaced an autonumber (e.g.0001) over the record's real name whenever the referenced object declared its title vianameField/titleFormat. The picker (LookupField) already resolved through the unified ADR-0079 resolver (getRecordDisplayName), so chip and picker disagreed on the same field.Changes
@object-ui/fields:LookupCellRenderernow fetches the referenced object's schema viadataSource.getObjectSchema(module-level cache — one metadata fetch per object, shared across cells) and resolves both $expand-ed record objects and fetch-on-demand records (useLookupName) throughgetRecordDisplayName, with the precedencedisplayField→nameField/displayNameField→titleFormat→ type-aware derivation (which excludes autonumber). The key heuristic remains only as the no-schema fallback, so data sources without schema metadata keep their previous behavior.@object-ui/fields:useLookupNamehonours the field's explicitdisplay_fieldand includes it in the resolution cache key.@object-ui/core:NON_TITLE_TYPESnow also excludes the ObjectStack spellingauto_number(the field-widget registry key), so type-aware derivation can never pick an autonumber as a record title.Out of scope: the picker's internal ordering (
titleFormatbeforedisplayField) is left untouched; within the nameField/titleFormat tier chip and picker now agree, which is what the issue requires.Tests
packages/fields/src/__tests__/lookupCellDisplayName.test.tsx(5 cases): nameField beats the autonumber suffix heuristic; titleFormat template resolution; explicitdisplay_fieldwins (the issue's documented workaround); fetch-on-demand primitive-id path resolves via schema; heuristic fallback when the data source has no schema API.auto_numberadded to theisTitleEligibleFieldtype table inrecord-title.test.ts.fields/plugin-detail/coresuites: 1512 passed (the oneDATEFORMATfailure is a pre-existing timezone-sensitive test, verified failing on a clean tree).tsc --noEmitclean for core and fields; eslint error count unchanged.