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 DatePicker not using custom dateFormat from locale #42485

Conversation

Rafael-Martins
Copy link
Contributor

@Rafael-Martins Rafael-Martins commented May 18, 2023

🤔 This is a ...

  • Bug fix

🔗 Related issue link

  1. Datepicker is not using custom dateFormat from locale #42119

💡 Background and solution

This issue is that the locale and context locale was not being considered in the code, so I added the code to merge locales and use it in the date format by the format prop. the order of priority in the locale is: componentProp > localeProp > localeContext

I will write some tests/demo for this if this is the right behavior!

📝 Changelog

Language Changelog
🇺🇸 English
🇨🇳 Chinese

☑️ 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 9183c64

Added global configuration for date format in Locale and used it in DatePicker. This enables consistent and customizable formatting of dates across components and locales.

🔍 Walkthrough

🤖 Generated by Copilot at 9183c64

  • Add dateFormat property to Locale interface to allow custom date format for components (link)
  • Use ConfigContext to get global locale and date format for DatePicker component (link, link)
  • Pass format prop to Picker component to display date according to locale and date format (link)

@github-actions
Copy link
Contributor

  • 🚨 Please fill changelog in the PR

    • Write with a developer-oriented perspective and narrative method, without describing the details of the repair
    • Describing the problem and the impact on the developer
    • describing the user-first site problem, not your solution
    • Refer: https://ant.design/changelog#501
  • 🚨 请填写 PR 中的 changelog

    • 请用面向开发者的角度叙述方式撰写,不描述修复细节
    • 描述问题和对开发者的影响
    • 描述用户第一现场的问题,而非你的解决方式
    • 参考:https://ant.design/changelog-cn#501

@github-actions
Copy link
Contributor

github-actions bot commented May 18, 2023

@Wxh16144
Copy link
Member

Great contribution, for which I am grateful. It seems that this solution is not correct, we should fix it in rc-pciker ( the dateFormat variable is not used in rc-pciker, maybe it was broken in some refactoring)

@@ -137,6 +145,7 @@ export default function generatePicker<DateType>(generateConfig: GenerateConfig<
superNextIcon={<span className={`${prefixCls}-super-next-icon`} />}
allowClear
transitionName={`${rootPrefixCls}-slide-up`}
format={locale!.dateFormat}
Copy link
Contributor

@linhf123 linhf123 May 19, 2023

Choose a reason for hiding this comment

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

dateFormat needs to be implemented in rc-picker

Copy link
Contributor

@linhf123 linhf123 May 19, 2023

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh, I see, I misunderstand the discussion, let me see if I can fix it in the rc-picker side and then bump it here! Do you happen to know the commit in which the issue occurred in the rc-picker?

Would it be better to close this pull request or save it for bump/upgrade?

Copy link
Contributor

Choose a reason for hiding this comment

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

It should be a refactoring that left this logic. I'll take time to find the relevant pr.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@any1024 Oh, that will help me, I tried to troubleshoot it by myself and did not got any success, I tried to look the changes, I also tested another rc-picker versions, such: 3.1.0, 3.2.x... also with no success

@linhf123
Copy link
Contributor

linhf123 commented May 19, 2023

You need to support the locale format in rc-picker
https://github.com/react-component/picker/blob/master/src/locale/en_US.ts

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.

None yet

3 participants