Skip to content

fix(modal): fix issue #3450 #3650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

fix(modal): fix issue #3450 #3650

wants to merge 1 commit into from

Conversation

James-9696
Copy link
Collaborator

@James-9696 James-9696 commented Aug 18, 2025

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:
    在vue2版本情况下,函数式插槽写法无响应,兼容vue2写法

What is the current behavior?

Issue Number: #3450

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • Bug Fixes

    • Ensured consistent rendering of modal body and footer slot content, preventing edge cases where single-node or text slots could render inconsistently or trigger warnings.
    • Improved stability when custom content is provided via slots in the modal.
  • New Features

    • None.
  • Documentation

    • None.
  • Refactor

    • None.
  • Tests

    • None.
  • Chores

    • None.
  • Revert

    • None.

Copy link

coderabbitai bot commented Aug 18, 2025

Walkthrough

The modal component in packages/vue/src/modal/src/pc.vue now wraps the rendered results of the default and footer slot invocations in single-element arrays, standardizing the return shape during render. No other logic or public API signatures were changed.

Changes

Cohort / File(s) Summary
Vue Modal slot return normalization
packages/vue/src/modal/src/pc.vue
Adjusted render branches to return [defaultSlot.call(...)] and [footerSlot.call(...)] instead of raw results, enforcing array return shape for default and footer slots.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I thump my paw—arrays in a row,
Slots now wrapped, neat as fresh snow.
One little bracket, snug and right,
Keeps render paths tidy and light.
With a hop and a wink, I cheer the day—
Consistent shapes all the Vue-way! 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-3450-issue

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the bug Something isn't working label Aug 18, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/vue/src/modal/src/pc.vue (1)

255-256: Optional: Normalize slot children for consistency and robustness

Your changes are correct and Vue will flatten nested arrays, but you can make slot handling more explicit by:

  • Preventing nested arrays ([[…]])
  • Filtering out null/undefined/false in one place

Apply these diffs to both PC and mobile-first renders:

packages/vue/src/modal/src/pc.vue

-                    ? [defaultSlot.call(this, { $modal: this }, h)]
+                    ? normalizeSlotChildren(defaultSlot.call(this, { $modal: this }, h))-                    ? [footerSlot.call(this, footerSlotParams, h)]
+                    ? normalizeSlotChildren(footerSlot.call(this, footerSlotParams, h))

packages/vue/src/modal/src/mobile-first.vue

-                              ? defaultSlot.call(this, { $modal: this }, h)
+                              ? normalizeSlotChildren(defaultSlot.call(this, { $modal: this }, h))-                        footerSlot ? footerSlot.call(this, footerSlotParams, h) : footerBottom
+                        footerSlot
+                          ? normalizeSlotChildren(footerSlot.call(this, footerSlotParams, h))
+                          : footerBottom

Add a single helper at module scope (above your render function):

// Normalize various slot return shapes into a flat children array
const normalizeSlotChildren = (result: any): any[] => {
  if (result == null || result === false) return []
  return Array.isArray(result) ? result : [result]
}

To catch any other slot-call sites that could benefit from this pattern:

rg -nP -C2 '\w+Slot\.call\(\s*this\s*,'
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3e3786d and a8eb6ee.

📒 Files selected for processing (1)
  • packages/vue/src/modal/src/pc.vue (2 hunks)
🔇 Additional comments (2)
packages/vue/src/modal/src/pc.vue (2)

254-261: LGTM: Array-wrapping the default slot result fixes Vue 2 children shape.

This ensures the 3rd argument to h(...) is always an array, which aligns with Vue 2’s render expectations. Nested arrays will be normalized by Vue, so this is backward-safe across Vue 2/3. No public API change introduced.


292-320: LGTM: Footer slot return wrapped in an array for consistency and Vue 2 compatibility.

Consistent with the body’s default slot handling and safe across Vue 2/3 due to children normalization.

@James-9696 James-9696 changed the title fix(modal): revise problem sheet #3450 fix(modal): fix issue #3450 Aug 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants