Uh oh!
There was an error while loading. Please reload this page.
fix(fields): inline lookup editor shows the selected record's name (#2125) - #2138
Merged
Conversation
…2125) Editing a lookup / master_detail / user / owner field inline in the data grid showed the "Select…" placeholder instead of the current record's name. The grid requests `$expand` for visible reference columns, so a lookup cell's value arrives as the related record OBJECT (`{ id, name }`), not a bare id. The read cell (`LookupCellRenderer`) resolves objects via the display-name path, but the inline editor (`LookupField`) only matched PRIMITIVE ids — `findOption(value)` with a strict `===` — so an object value never resolved and `selectedOptions` stayed empty. The hydration effect then made it worse by calling `findOne(referenceTo, <object>)` with a bogus id. - `LookupField` resolves an expanded-reference object directly into its display option (mirroring the read cell), and skips the per-object fetch. - Object values are normalised to their id for option matching, multi-select toggle, and chip removal. - `FieldEditWidget` renders the relational pickers `compact` inline — the same single-line borderless trigger the line-item grid uses — so the record name shows IN the trigger instead of a chip stacked above a "Select…" button. Adds regression tests for the expanded-object value (compact + full mode), the preserved bare-id findOne hydration path, and FieldEditWidget forwarding compact. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
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 freeto 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.
Closes#2125.
Problem
Editing a
lookup/master_detail/user/ownerfield inline in the data grid showed the "选择… / Select…" placeholder instead of the currently-selected record's name. The value was never wrong (the correct record id persisted, and the read-mode cell rendered the name) — only the inline editor trigger failed to display it.Root cause
The grid requests
$expandfor visible reference columns (buildExpandFields), so a lookup cell's value arrives as the related record object{ id, name, … }, not a bare id.LookupCellRenderer) resolves object values via the display-name path — so it always worked.LookupField) only matched primitive ids:findOption(value)does a strictopt.value === value. An object value never matches →selectedOptionsstays empty → placeholder. The hydration effect then made it worse by callingfindOne(referenceTo, <object>)with a bogus id (which is why waiting 2.5 s never helped).This is exactly the "align the editor's resolution with the read renderer's" the issue asked for.
Fix
LookupField.tsxrecordToOption, mirroring the read cell) — no fetch needed.findOne(<object>); only bare ids are fetched.FieldEditWidget.tsxcompactinline (the same single-line, borderless trigger the line-itemGridFielduses), so the record name shows in the trigger — in full mode the trigger always renders "Select" (the name lives in a chip stacked above), which is the double-stackcompactwas built to avoid in a cell.Tests
complex-widgets.test.tsx: expanded-object value resolves in compact (trigger) and full (badge) mode with no bogus fetch; the bare-idfindOnehydration path still works;FieldEditWidgetforwardscompactto the relational widget.@object-ui/fieldssuite green (4977 passed / 24 skipped), including theFieldEditWidgetdrift-guard, plusturbo run build --filter=@object-ui/fields(type gate) green.Related
🤖 Generated with Claude Code