[7123] Search and Browse dialogs should either hide existing selected items or show them as already selected#4810
[7123] Search and Browse dialogs should either hide existing selected items or show them as already selected#4810jvega190 wants to merge 2 commits intocraftercms:developfrom
Conversation
… items or show them as already selected
WalkthroughPasses optional Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
ui/app/src/components/FormsEngine/controls/NodeSelector.tsx (1)
485-485: Embedded component objectIds are included inpreselectedPaths.For embedded items,
item.keyis the objectId (a UUID), not a file path. These entries are harmless — they won't match any path in the Browse/Search dialogs — but including them is semantically imprecise. Consider filtering them out alongside the existing.filter(Boolean):♻️ Suggested refinement
- preselectedPaths: value.map((item) => item.key).filter(Boolean), + preselectedPaths: value.filter((item) => !item.component).map((item) => item.key).filter(Boolean),Apply the same change at both line 485 (browse) and line 508 (search).
Also applies to: 508-508
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ui/app/src/components/FormsEngine/controls/NodeSelector.tsx` at line 485, preselectedPaths currently includes embedded component objectIds because it uses value.map(item => item.key).filter(Boolean); change the filter to exclude non-path keys (e.g., objectIds) so only real file paths remain — for example, replace .filter(Boolean) with a predicate that checks the key looks like a path (contains '/' or does not match UUID pattern) where preselectedPaths is set in NodeSelector.tsx (the value.map((item) => item.key) expression used for both the browse and search assignments around the preselectedPaths lines).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@ui/app/src/components/FormsEngine/controls/ImagePicker.tsx`:
- Line 207: ImagePicker currently passes preselectedPaths: [value] which can
become [''] when value is an empty string; update the two places that set
preselectedPaths (the browse and search calls in ImagePicker) to avoid empty
strings by filtering falsy values (e.g., use [value].filter(Boolean) or
conditional logic to pass [] when value is empty) so NodeSelector never receives
['']; reference the preselectedPaths prop and the value variable in ImagePicker
and apply the same change for both the browse and search invocations.
---
Nitpick comments:
In `@ui/app/src/components/FormsEngine/controls/NodeSelector.tsx`:
- Line 485: preselectedPaths currently includes embedded component objectIds
because it uses value.map(item => item.key).filter(Boolean); change the filter
to exclude non-path keys (e.g., objectIds) so only real file paths remain — for
example, replace .filter(Boolean) with a predicate that checks the key looks
like a path (contains '/' or does not match UUID pattern) where preselectedPaths
is set in NodeSelector.tsx (the value.map((item) => item.key) expression used
for both the browse and search assignments around the preselectedPaths lines).
There was a problem hiding this comment.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@ui/app/src/components/FormsEngine/controls/ImagePicker.tsx`:
- Line 207: The preselectedPaths array was being populated with an empty string
when no image was selected; update both dialog flows in ImagePicker (the browse
and search dialog invocations that set preselectedPaths) to use a guarded
expression like value ? [value] : [] so they won't pass [''] when value is empty
(note value is derived from defaultValue ?? ''), ensuring both the browse and
search usages of preselectedPaths follow the same pattern.
craftercms/craftercms#7123
Summary by CodeRabbit