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: ConfigProvider merge form validateMessages not inheriting from parent bug #43239

Merged
merged 2 commits into from Jul 6, 2023

Conversation

Wxh16144
Copy link
Member

@Wxh16144 Wxh16144 commented Jun 28, 2023

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Internationalization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Workflow
  • Other (about what?)

🔗 Related issue link

fix: #43210

💡 Background and solution

#40533 Bug caused by commit

Example Code

import React from 'react';
import { Button, ConfigProvider, Form, Input } from 'antd';

const MyCustomForm = () => (
  <Form>
    <Form.Item name="name" label="Name" rules={[{ required: true }]}>
      <Input />
    </Form.Item>
    <Button type="primary" htmlType="submit">Submit</Button>
  </Form>
)

export default () => (
  <ConfigProvider>
    <MyCustomForm />
    <ConfigProvider form={{ validateMessages: { required: '必填' } }}>
      <MyCustomForm />
      <ConfigProvider>
        <MyCustomForm />
      </ConfigProvider>
    </ConfigProvider>
  </ConfigProvider>
);

Before

image

After

image

📝 Changelog

Language Changelog
🇺🇸 English Fixed nested ConfigProvider will miss form.validateMessages config.
🇨🇳 Chinese 修复 ConfigProvider 嵌套使用时,form.validateMessages 配置会丢失的问题。

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

🚀 Summary

🤖 Generated by Copilot at afb445b

This pull request adds a feature to customize the validation messages of the Form component using the validateMessages prop of the ConfigProvider component. It also fixes a bug related to nested ConfigProvider and Form components, and adds a test case to verify the functionality.

🔍 Walkthrough

🤖 Generated by Copilot at afb445b

  • Add the validateMessages prop to the ConfigProvider component and its context, to allow customizing the error messages of nested Form components (link, link, link).

@github-actions
Copy link
Contributor

github-actions bot commented Jun 28, 2023

@codecov
Copy link

codecov bot commented Jun 28, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (41fe4ce) 100.00% compared to head (afb445b) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##            master    #43239   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          648       648           
  Lines        10965     10966    +1     
  Branches      2978      2979    +1     
=========================================
+ Hits         10965     10966    +1     
Impacted Files Coverage Δ
components/config-provider/context.ts 100.00% <ø> (ø)
components/config-provider/index.tsx 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@afc163
Copy link
Member

afc163 commented Jun 28, 2023

修复未合并父级 Form validateMessages 错误

changelog 写用户面对的问题,不只写解法。

@li-jia-nan li-jia-nan changed the title fix: ConfigProvider merge form validateMessages not inheriting from parent bug fix: ConfigProvider merge form validateMessages not inheriting from parent bug Jun 28, 2023
@zombieJ zombieJ merged commit 70abc90 into ant-design:master Jul 6, 2023
66 checks passed
@yoyo837
Copy link
Contributor

yoyo837 commented Jul 6, 2023

v4是照搬的, 是否有类似问题?

@Wxh16144

This comment was marked as off-topic.

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.

ConfigProvider > from > validateMessages not working
4 participants