Skip to content

fix(component-library): treat slot content that renders only comments as empty - #1392

Open
Arnold Stoba (arnoldstoba) wants to merge 4 commits into
mainfrom
fix/slot-comment-only-content
Open

Arnold Stoba (arnoldstoba) wants to merge 4 commits into
mainfrom
fix/slot-comment-only-content

Conversation

@arnoldstoba

@arnoldstoba Arnold Stoba (arnoldstoba) commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

What?

hasSlotContent treats slot content that renders only comments as empty, also inside v-for fragments. It also accepts slots typed with defineSlots().

Why?

Filtering a list with <template v-for> and v-if, as the Vue docs recommend, renders only comments when every item is hidden. hasSlotContent counted that as content, so components that render an optional slot's wrapper only when it has content showed an empty wrapper. For example, with the upcoming mt-message, a user message with only an image attachment rendered an empty text bubble:

<mt-message from="user">
  <template #attachments>…</template>
  <template v-for="(text, index) in texts" :key="index">
    <mt-text v-if="text.text" size="xs">{{ text.text }}</mt-text>
  </template>
</mt-message>

Vue applies the same rule when it decides whether <slot> shows its fallback content.

How?

One recursive check: comments, empty text and fragments whose children are all empty count as empty.

Testing?

slot.spec.ts renders real templates: a hidden v-if, a v-for with every item hidden and one with an item shown.

Anything Else?

No visible change for existing components: mt-base-field is the only caller today, and every field fills its error slot with a single v-if, so there is no changeset. #1389 and #1399 carry this commit and need a rebase after this is merged.

@vercel

vercel Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
meteor-docs Ready Ready Preview Oct 9, 2026 12:20pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
meteor-storybook Ignored Ignored Preview Oct 9, 2026 12:20pm UTC

Request Review

This branch was successfully deployed

2 active (1 outdated) deployments
Preview – meteor-docs — 5e12e296 Deployed Oct 9, 2026 by vercel[bot]
Preview – meteor-storybook — d4416bec Deployed Oct 9, 2026 by vercel[bot]
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.

1 participant