Skip to content

fix: LookupField shows no visual feedback after RecordPickerDialog selection#1095

Merged
hotlong merged 2 commits intomainfrom
copilot/fix-popup-selection-feedback
Mar 19, 2026
Merged

fix: LookupField shows no visual feedback after RecordPickerDialog selection#1095
hotlong merged 2 commits intomainfrom
copilot/fix-popup-selection-feedback

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 19, 2026

Selecting a record in the RecordPickerDialog (Level 2) updates the form value but the LookupField UI shows nothing — no badge, no label. Affects both single and multi-select.

Root cause: findOption only searches staticOptions and fetchedOptions (Level 1 popover). Records loaded by the dialog's own fetch are invisible to the parent.

Changes

  • RecordPickerDialog: New optional onSelectRecords callback returns full record objects alongside IDs. A selectedRecordsMap ref persists record data across page navigation for multi-select.
  • LookupField: New pickerResolvedRecords state caches records from the dialog. findOption checks this as a third fallback source.
// RecordPickerDialog now passes back record objects
<RecordPickerDialog
  onSelect={onChange}                          // IDs (unchanged)
  onSelectRecords={handlePickerSelectRecords}  // full records → display cache
/>

Tests

4 new tests covering onSelectRecords for single/multi-select and end-to-end LookupField badge rendering after dialog selection.

Original prompt

lookup 字段弹出窗口选中记录之后界面看不出任何效果。并且需要考虑单选和多选两种情况。


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectui Ready Ready Preview, Comment Mar 19, 2026 10:17am
objectui-demo Ready Ready Preview, Comment Mar 19, 2026 10:17am
objectui-storybook Ready Ready Preview, Comment Mar 19, 2026 10:17am

Request Review

…Dialog selection

Add `onSelectRecords` callback to RecordPickerDialogProps that returns
full record objects alongside IDs. LookupField caches these records
so findOption can resolve display labels after the dialog closes.

Handles both single-select and multi-select modes. Multi-select uses
a selectedRecordsMap ref to persist record data across page navigation.

Includes 4 new tests validating the end-to-end selection display flow.

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix lookup field popup selection feedback fix: LookupField shows no visual feedback after RecordPickerDialog selection Mar 19, 2026
Copilot AI requested a review from hotlong March 19, 2026 10:15
@hotlong hotlong marked this pull request as ready for review March 19, 2026 10:29
Copilot AI review requested due to automatic review settings March 19, 2026 10:29
@hotlong hotlong merged commit 94f85c7 into main Mar 19, 2026
4 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a LookupField UX bug where selecting records via the Level 2 RecordPickerDialog updates the underlying value but doesn’t update the LookupField’s visible label/badges, by returning full record objects from the picker and caching them for display.

Changes:

  • Added optional onSelectRecords(records) callback to RecordPickerDialog and a selectedRecordsMap cache to retain selected record objects across paging (multi-select).
  • Added pickerResolvedRecords cache in LookupField and updated findOption to also resolve display data from dialog-selected records.
  • Added tests for onSelectRecords behavior and for LookupField badge rendering after Level 2 selection; updated CHANGELOG.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
packages/fields/src/widgets/RecordPickerDialog.tsx Adds onSelectRecords callback and caches selected record objects for multi-select paging.
packages/fields/src/widgets/LookupField.tsx Caches dialog-selected records and extends option resolution to show badges/labels after dialog selection.
packages/fields/src/record-picker.test.tsx Adds tests for onSelectRecords and end-to-end LookupField display after dialog selection.
CHANGELOG.md Documents the LookupField selection display fix and the new callback.

Comment on lines +311 to +314
const mapped = records.map(r => recordToOption(r, displayField, idField, descriptionField));
setPickerResolvedRecords(mapped);
},
[displayField, idField, descriptionField],
]),
);
expect(onOpenChange).toHaveBeenCalledWith(false);
});
Comment on lines 605 to +612
const handleConfirm = useCallback(() => {
onSelect(Array.from(pendingSelection));
const ids = Array.from(pendingSelection);
onSelect(ids);
// Build the full record array from the cache for the caller
const selectedRecords = ids
.map(id => selectedRecordsMap.current.get(id))
.filter(Boolean);
onSelectRecords?.(selectedRecords);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants