Skip to content

fix: 🐛 修复Form组件rules属性,没有按照顺序执行问题#808

Merged
Moonofweisheng merged 3 commits into
Moonofweisheng:masterfrom
GNaIq-GnAw:feature/fix_form
Jan 6, 2025
Merged

fix: 🐛 修复Form组件rules属性,没有按照顺序执行问题#808
Moonofweisheng merged 3 commits into
Moonofweisheng:masterfrom
GNaIq-GnAw:feature/fix_form

Conversation

@GNaIq-GnAw

@GNaIq-GnAw GNaIq-GnAw commented Dec 28, 2024

Copy link
Copy Markdown
Contributor

🤔 这个 PR 的性质是?(至少选择一个)

  • 日常 bug 修复
  • 新特性提交
  • 站点、文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • TypeScript 定义更新
  • CI/CD 改进
  • 包体积优化
  • 性能优化
  • 功能增强
  • 国际化改进
  • 代码重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他改动(是关于什么的改动?)

🔗 相关 Issue

💡 需求背景和解决方案

form组件在校验规则时,并不是按照rules属性的顺序提示错误信息的,解决方案是对showMessage方法中messages变量进行排序

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充

Summary by CodeRabbit

  • 新特性
    • 改进了错误消息的显示逻辑,确保错误消息按照特定顺序呈现。
    • 增加了过滤步骤,以确保错误属性包含在子组件属性列表中。

@vercel

vercel Bot commented Dec 28, 2024

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
wot-design-uni ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 28, 2024 1:37am

@coderabbitai

coderabbitai Bot commented Dec 28, 2024

Copy link
Copy Markdown

变更概览

走查

wd-form.vue 组件中,showMessage 函数的错误消息处理逻辑进行了优化。新的实现增加了对错误属性的过滤和排序机制,确保只显示属于子组件属性列表中的错误消息,并按照属性在 childrenProps 数组中的索引顺序进行排序。

变更

文件路径 变更摘要
src/uni_modules/wot-design-uni/components/wd-form/wd-form.vue 修改 showMessage 函数,增加错误消息过滤和排序逻辑

可能相关的 PR

建议的审阅者

  • Moonofweisheng

诗歌

🐰 表单校验,兔子轻歌
错误消息,排序有序
属性过滤,逻辑精妙
用户体验,悄然提升
代码如诗,兔子微笑 🌟


📜 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 1d0b11b and ebce309.

📒 Files selected for processing (1)
  • src/uni_modules/wot-design-uni/components/wd-form/wd-form.vue (1 hunks)
🔇 Additional comments (2)
src/uni_modules/wot-design-uni/components/wd-form/wd-form.vue (2)

151-152: 建议校验子组件 prop 是否在 childrenProps 中时具备冗余判断
当前使用 childrenProps.includes(error.prop) 进行过滤能确保排序时不会出现 .indexOf 返回 -1 的情况,逻辑上十分清晰。若后续有动态增减子组件的场景,需确保 childrenProps 数组更新的时机与错误信息的生成时机一致,以防止可能的同步问题。


154-156: 建议在此处编写自动化测试或单测以覆盖错误信息排序逻辑
通过对 messages 数组进行基于 childrenProps 索引的排序,能有效确保错误信息按照表单中各项的先后顺序呈现。为了避免后续迭代出现意外回归,建议编写单测来验证:

  1. 多个错误同时出现时,排序是否符合预期。
  2. childrenProps 更新后,错误信息的排序能否正确匹配新顺序。

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • 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. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

@netlify

netlify Bot commented Dec 28, 2024

Copy link
Copy Markdown

Deploy Preview for wot-design-uni ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit ebce309
🔍 Latest deploy log https://app.netlify.com/sites/wot-design-uni/deploys/676f55eb4c1c980008cba8bc
😎 Deploy Preview https://deploy-preview-808--wot-design-uni.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@GNaIq-GnAw GNaIq-GnAw changed the title fix: 🐛 修复Form组件rules属性,没有按照顺序执行问题 #799 fix: 🐛 修复Form组件rules属性,没有按照顺序执行问题 Dec 28, 2024
@Moonofweisheng
Moonofweisheng merged commit 834cd8e into Moonofweisheng:master Jan 6, 2025
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.

2 participants