-
Notifications
You must be signed in to change notification settings - Fork 319
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
base: dev
Are you sure you want to change the base?
Conversation
WalkthroughThe 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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
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
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 robustnessYour 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 placeApply 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)) + : footerBottomAdd 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.
📒 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.
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
在vue2版本情况下,函数式插槽写法无响应,兼容vue2写法
What is the current behavior?
Issue Number: #3450
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
Bug Fixes
New Features
Documentation
Refactor
Tests
Chores
Revert