Skip to content
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

fix(form): setFieldsValue未能触发校验 #2400

Merged
merged 1 commit into from
Jul 2, 2024

Conversation

Alex-huxiyang
Copy link
Collaborator

@Alex-huxiyang Alex-huxiyang commented Jul 1, 2024

  • 日常 bug 修复

Summary by CodeRabbit

  • 新功能
    • 在表单初始化时自动验证字段。
    • 在更新表单项时自动验证字段。

Copy link

coderabbitai bot commented Jul 1, 2024

Walkthrough

这次变更主要集中在两个文件中的 FormStore 类。对 src/packages/form/useform.taro.ts 文件进行了修改,在 initialize 方法中添加了对 this.validateFields() 的调用。而对于 src/packages/form/useform.ts 文件,则在 updateItems 方法中添加了对 this.validateFields() 的调用。这些变更旨在加强表单字段的初始化和更新时的验证逻辑。

Changes

文件路径 变更摘要
src/packages/form/useform.taro.ts FormStore 类的 initialize 方法中添加了 this.validateFields() 的调用。
src/packages/form/useform.ts FormStore 类的 updateItems 方法中添加了 this.validateFields() 的调用。

🐰✨

表单初始验,字段记心间,
更新未曾忘,逻辑更完善。
代码变迁续,功能更强健,
我们齐欢庆,软件更圆满。

🌼


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e1ad53e and fb2d2ec.

Files selected for processing (2)
  • src/packages/form/useform.taro.ts (1 hunks)
  • src/packages/form/useform.ts (1 hunks)
Additional comments not posted (2)
src/packages/form/useform.ts (1)

116-116: 优化建议:在设置字段值后触发校验。

添加 this.validateFields() 以确保在每次更新字段值时进行校验,这是一个合理的改进。但需要注意,频繁的校验可能会影响性能,特别是在表单字段较多或校验规则复杂时。

src/packages/form/useform.taro.ts (1)

116-116: 校验初始化字段值的改进。

initialize 方法中添加 this.validateFields() 用于初始化时进行字段校验,确保初始状态符合预期。这是一个积极的改变,有助于提高表单的健壮性。同样,建议评估其对初始化加载时间的影响。


Tip

Early access features: disabled

We are currently testing the following features in early access:

  • OpenAI gpt-4o model for code reviews and chat: OpenAI claims that this model is better at understanding and generating code than the previous models. We seek your feedback over the next few weeks before making it generally available.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.
  • Please join our Discord Community to provide feedback and report issues.

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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

Copy link

codecov bot commented Jul 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.98%. Comparing base (e1ad53e) to head (fb2d2ec).

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #2400   +/-   ##
=======================================
  Coverage   85.98%   85.98%           
=======================================
  Files         217      217           
  Lines       22827    22828    +1     
  Branches     2540     2540           
=======================================
+ Hits        19628    19629    +1     
  Misses       3194     3194           
  Partials        5        5           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Alex-huxiyang Alex-huxiyang linked an issue Jul 1, 2024 that may be closed by this pull request
@Alex-huxiyang Alex-huxiyang changed the title fix(form): setFields未触发校验 fix(form): setFieldsValue未能触发校验 Jul 1, 2024
@xiaoyatong xiaoyatong merged commit 82c05a9 into jdf2e:next Jul 2, 2024
5 checks passed
@Alex-huxiyang Alex-huxiyang deleted the hxy/0701/calendar branch July 9, 2024 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Form表单手动设置值没有重置校验状态
2 participants