Skip to content

fix(components): empty document displays empty object instead of blank card COMPASS-9814#8247

Open
dudaschar wants to merge 3 commits into
mainfrom
COMPASS-9814
Open

fix(components): empty document displays empty object instead of blank card COMPASS-9814#8247
dudaschar wants to merge 3 commits into
mainfrom
COMPASS-9814

Conversation

@dudaschar

Copy link
Copy Markdown
Collaborator

Description

When using $project in aggregation pipelines, if that's no final content to the document, the output looks broken:

image

The readonly document component now returns {} if that's no content to be displayed, which make clear the document exist, but that's no content to preview.
image
image

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added
  • If this change updates the UI, screenshots/videos are added and a design review is requested
  • If this change could impact the load on the MongoDB cluster, please describe the expected and worst case impact
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@dudaschar
dudaschar requested a review from a team as a code owner July 16, 2026 14:28
@dudaschar
dudaschar requested a review from alenakhineika July 16, 2026 14:28
@github-actions github-actions Bot added the fix label Jul 16, 2026
Comment thread packages/compass-crud/src/components/readonly-document.tsx Outdated
className={emptyDocumentStyles}
data-testid="readonly-document-empty"
>
{'{}'}

@gribnoysup gribnoysup Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd maybe go for something like (empty document), this feels more aligned with the document card being distinct from the json view (this is also similar to how we indicate an empty array in the Document card)

Suggested change
{'{}'}
<em>(empty document)</em>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Also looks nicer 👍

image

}
return (
<>
<DocumentList.Document

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we might want this change in the DocumentList.Document component itself, not in the list, to make sure that all these Document components everywhere consistently show an empty placeholder even when used as a one-off. But maybe I'm missing some reason for it to be only in the list here 🤔

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

No, you are right. I added initially in the readonly the aggregation uses, but changing in the higher level will make the change broader.

[editable, extraGutterWidth]
);

const emptyDocumentOffset = useMemo(

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Matching the same spacing for the content in a regular document preview, so they look alike when both are present in the same page.

@dudaschar
dudaschar requested a review from gribnoysup July 16, 2026 16:01
@dudaschar dudaschar self-assigned this Jul 16, 2026
@dudaschar
dudaschar requested a review from Anemy July 16, 2026 16:02
@dudaschar dudaschar changed the title fix(crud): empty document displays empty object instead of blank card COMPASS-9814 fix(components): empty document displays empty object instead of blank card COMPASS-9814 Jul 16, 2026
@dudaschar dudaschar added the no release notes Fix or feature not for release notes label Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix no release notes Fix or feature not for release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants