Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(popconfirm): [popconfirm] enable message slot #3176

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

Merged
merged 1 commit into from
Apr 12, 2025

Conversation

betavs
Copy link
Contributor

@betavs betavs commented Mar 25, 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:

What is the current behavior?

Issue Number: #3129

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features
    • Enhanced the popconfirm component to support a custom message slot with fallback content.
    • Updated slot labels for improved clarity.
    • Introduced new demo examples showcasing the custom message functionality for both desktop and mobile views.
    • Added automated tests to ensure the new custom message behavior works as expected.

Copy link

coderabbitai bot commented Mar 25, 2025

Walkthrough

The pull request updates the popconfirm component by revising its slot API. The existing footer slot’s description is corrected, and a new message slot is introduced with multi-language documentation and support for both 'pc' and 'mobile-first' modes. Additionally, new demo components, tests, and web documentation entries have been added to showcase the custom message slot usage. The core popconfirm component is updated to render message content via a named slot with a fallback to the default message value.

Changes

File(s) Change Summary
.../apis/popconfirm.js Updated API: Changed the footer slot description from “default slot” to “footer slot” and added a new message slot with empty type/default value, multi-language descriptions, and demo references.
.../pc/app/popconfirm/{slot-message-composition-api.vue, slot-message.vue, slot-message.spec.ts, webdoc/popconfirm.js} Added new demo files: Introduced Vue components (one using the Composition API and one standard Vue file) for demonstrating custom message slot usage, including corresponding Playwright tests and a new demo entry in web documentation.
.../popconfirm/src/pc.vue Modified core component: Replaced direct message interpolation with a <slot> element (named "message") to render the message content with a fallback to the default message if no slot content is provided.

Possibly related PRs

Suggested reviewers

  • zzcr

Poem

Hopping through code with a gentle bound,
New slots and tests are joyfully found.
The footer refined, the message shines bright,
A bunny's delight in each slot-filled byte.
With hops and cheers, our code takes flight! 🐰

Happy coding under the moonlit night!

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

examples/sites/demos/apis/popconfirm.js

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-vue".

(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-vue@latest --save-dev

The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

examples/sites/demos/pc/app/popconfirm/slot-message-composition-api.vue

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-vue".

(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-vue@latest --save-dev

The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

examples/sites/demos/pc/app/popconfirm/slot-message.spec.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-vue".

(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-vue@latest --save-dev

The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

  • 2 others

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4bd911a and 4b9e892.

📒 Files selected for processing (5)
  • examples/sites/demos/apis/popconfirm.js (1 hunks)
  • examples/sites/demos/pc/app/popconfirm/slot-message-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/popconfirm/slot-message.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/popconfirm/slot-message.vue (1 hunks)
  • examples/sites/demos/pc/app/popconfirm/webdoc/popconfirm.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • examples/sites/demos/pc/app/popconfirm/webdoc/popconfirm.js
  • examples/sites/demos/pc/app/popconfirm/slot-message.vue
  • examples/sites/demos/pc/app/popconfirm/slot-message-composition-api.vue
  • examples/sites/demos/pc/app/popconfirm/slot-message.spec.ts
  • examples/sites/demos/apis/popconfirm.js

🪧 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.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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 bug Something isn't working enhancement New feature or request (功能增强) labels Mar 25, 2025
Copy link

Walkthrough

This pull request introduces a new feature to the popconfirm component by enabling a message slot. This allows users to customize the message content displayed within the popconfirm component, enhancing flexibility and usability.

Changes

File Summary
examples/sites/demos/apis/popconfirm.js Added a new message slot for customization.
examples/sites/demos/pc/app/popconfirm/slot-message-composition-api.vue New demo file showcasing the usage of the message slot with the Composition API.
examples/sites/demos/pc/app/popconfirm/slot-message.spec.ts Added test to verify custom message content in the popconfirm.
examples/sites/demos/pc/app/popconfirm/slot-message.vue New demo file showcasing the usage of the message slot with the Options API.
examples/sites/demos/pc/app/popconfirm/webdoc/popconfirm.js Documentation updated to include the new message slot feature.
packages/vue/src/popconfirm/src/pc.vue Modified the popconfirm component to support the message slot.

@@ -0,0 +1,22 @@
<template>
<div>
<tiny-popconfirm :title="title" :message="message" ref="popconfirmRef">

Choose a reason for hiding this comment

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

Ensure that the message prop is correctly passed and utilized within the tiny-popconfirm component to avoid potential rendering issues.

@@ -0,0 +1,30 @@
<template>
<div>
<tiny-popconfirm :title="title" :message="message" ref="popconfirm">

Choose a reason for hiding this comment

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

Ensure that the message prop is correctly passed and utilized within the tiny-popconfirm component to avoid potential rendering issues.

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)
examples/sites/demos/pc/app/popconfirm/slot-message-composition-api.vue (1)

14-22: Composition API implementation looks good.

The script setup implements all necessary variables as reactive refs and imports the required components. Note that popconfirmRef is defined but not used in the current implementation - this is fine if it's intended for future use or demonstration purposes.

Consider adding comments to explain the purpose of popconfirmRef if it's intended for future functionality.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9cf817a and 4bd911a.

📒 Files selected for processing (6)
  • examples/sites/demos/apis/popconfirm.js (1 hunks)
  • examples/sites/demos/pc/app/popconfirm/slot-message-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/popconfirm/slot-message.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/popconfirm/slot-message.vue (1 hunks)
  • examples/sites/demos/pc/app/popconfirm/webdoc/popconfirm.js (1 hunks)
  • packages/vue/src/popconfirm/src/pc.vue (1 hunks)
🔇 Additional comments (8)
examples/sites/demos/pc/app/popconfirm/slot-message.vue (2)

1-12: Looks good, demonstrates the new message slot effectively.

The template structure clearly shows how to use the message slot to customize the content of a popconfirm component. The implementation uses proper slot naming conventions and demonstrates the feature with a clear example.


14-30: Component implementation is clean and properly structured.

The script section correctly imports the necessary components, registers them, and provides the data properties needed for the demo. The custom message text is properly defined as a separate data property.

examples/sites/demos/pc/app/popconfirm/slot-message.spec.ts (1)

1-11: Test case effectively validates the custom message slot.

The test appropriately navigates to the demo page, locates the popconfirm component, and verifies that it contains the expected custom message text. The implementation follows Playwright testing best practices with proper locator usage and expectations.

examples/sites/demos/pc/app/popconfirm/webdoc/popconfirm.js (1)

81-92: Documentation for the new message slot is well-structured.

The added demo entry follows the existing pattern and includes proper localization for both names and descriptions. The documentation clearly explains the purpose of the message slot and references the appropriate demo file.

packages/vue/src/popconfirm/src/pc.vue (1)

30-32: Great implementation of the message slot with proper fallback.

The change effectively introduces a named slot for customizing the message content while maintaining backward compatibility by using the original message prop as a fallback. This pattern follows Vue.js best practices for slot implementation.

examples/sites/demos/pc/app/popconfirm/slot-message-composition-api.vue (1)

1-12: Well-structured template for demonstrating the message slot.

The template correctly showcases the usage of the new message slot feature in the popconfirm component, with proper reference slot implementation for the trigger button.

examples/sites/demos/apis/popconfirm.js (2)

165-165: Improved description accuracy.

The English description for the footer slot has been updated from "default slot" to "footer slot", which more accurately reflects its purpose.


171-182: New message slot properly documented.

The new message slot has been correctly added to the API documentation with appropriate descriptions in both Chinese and English. The slot is configured to work in both PC and mobile-first modes, and links to the correct demo example.

@kagol kagol removed the bug Something isn't working label Mar 31, 2025
@betavs betavs force-pushed the feature/popconfirm-slot-message branch from 4bd911a to 4b9e892 Compare April 11, 2025 04:23
@zzcr zzcr merged commit 1dfdc4e into opentiny:dev Apr 12, 2025
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request (功能增强)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants