feat(grid): item-typeahead auto-fill from a lookup column#1565
Merged
Conversation
When a lookup cell's record is selected, GridField copies the record's fields into any sibling column of the same name (e.g. a product's unit_price + description), then recomputes computed columns — the catalog-typeahead every invoicing tool has (QuickBooks / Stripe / NetSuite). Opt out per column with `autofill: false`. - LookupField: optional `onSelectRecord(record)` surfaces the full selected record (not just its id); drives the update in single-select. - GridField: pure exported `lookupAutofillPatch(columns, col, record)` builds the FK-id + matching-siblings patch; wired into the lookup cell. - Live e2e: New Invoice picks a catalog product → description + unit_price auto-fill, amount computes, and all of it persists in the atomic batch. 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 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.
Why
Finishes the line-item editor: picking a catalog item (e.g. a Product) should drop its details (unit price, description) into the row — the typeahead behaviour QuickBooks / Stripe / NetSuite all have.
What
GridField— when a lookup cell's record is selected, copy any of the record's fields whose names match a sibling column (e.g. productunit_price/description) into the row, then recompute computed columns. Opt out per column withautofill: false. New pure exportlookupAutofillPatch(columns, col, record)(unit-tested).LookupField— optionalonSelectRecord(record)callback surfaces the full selected record (not just its id); in single-select it drives the update so the host owns the resulting value change. (Read off props via the existing index signature — no shared-type change.)Verification
GridFieldtests (incl. auto-fill copies same-named siblings; respectsautofill: false).unit_price29.99 +descriptionauto-fill → Qty 2 → computed Amount 59.98 → product/description/unit_price/amount all persisted in the atomic batch; the blank ghost line is not saved.🤖 Generated with Claude Code