Repository navigation
fix(ui): fall back to own file when hasMany thumbnail upload is empty - #19237
digitalwerber wants to merge 1 commit into
Conversation
Without `admin.useAsThumbnail`, the thumbnail of a card resolves from the first upload field and falls back to the document itself, so upload collections show their own file. An empty `hasMany` upload field (`[]`) resolved to `undefined` instead of falling back, so grid view cards and the Recents and Pinned dashboard widget showed the placeholder icon instead of the file. An empty single upload field already fell back correctly.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Empty-field fallback behavior packages/ui/src/utilities/getDocumentThumbnail.ts, packages/ui/src/utilities/getDocumentThumbnail.spec.ts |
The utility checks that an array contains an item before selecting its first value. Tests verify fallback to the document thumbnail for empty or missing upload fields and precedence for a populated hasMany field. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers: germanjablo
Merge Risk: 
Minimal · up to 5a141
-
The localized thumbnail fallback is supported by matching coverage for empty, missing, and populated upload fields.
Pre-merge checks: 
5
-
Full details: Linked Issues check
-
Explanation
Issue
#19234requiresgetDocumentThumbnailto use the upload document when the configuredhasManyfield is empty. The change treats[]as empty and selectsdocas the fallback. The tests cover emptyhasMany, empty single upload, absent field, and populatedhasManyprecedence.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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 @coderabbitai help to get the list of available commands.
What?
getDocumentThumbnailfalls back to the document itself when the thumbnail field is an emptyhasManyupload.Why?
An empty single upload field already fell back to the document, an empty
hasManyfield ([]) resolved toundefined. Upload collections with an attachments-style field therefore showed the placeholder icon in grid cards and dashboard widgets instead of their own file.How?
Treat an empty array like an empty value. Adds unit cases for empty single, empty
hasMany, filledhasManyand no field.Fixes #19234