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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions components/date-picker/generatePicker/generateSinglePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ export default function generatePicker<DateType>(generateConfig: GenerateConfig<
...restProps
} = props;

const { getPrefixCls, direction, getPopupContainer } = useContext(ConfigContext);
const {
getPrefixCls,
direction,
getPopupContainer,
locale: ctxLocale,
} = useContext(ConfigContext);
const prefixCls = getPrefixCls('picker', customizePrefixCls);
const { compactSize, compactItemClassnames } = useCompactItemContext(prefixCls, direction);
const innerRef = React.useRef<RCPicker<DateType>>(null);
Expand Down Expand Up @@ -120,7 +125,10 @@ export default function generatePicker<DateType>(generateConfig: GenerateConfig<
</>
);

const [contextLocale] = useLocale('DatePicker', enUS);
const [contextLocale] = useLocale('DatePicker', {
...(ctxLocale?.DatePicker ?? enUS),
dateFormat: ctxLocale?.dateFormat,
});

const locale = { ...contextLocale, ...props.locale! };

Expand All @@ -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

@Rafael-Martins Rafael-Martins May 19, 2023

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

{...additionalProps}
{...restProps}
{...additionalOverrideProps}
Expand Down
1 change: 1 addition & 0 deletions components/locale/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const ANT_MARK = 'internalMark';

export interface Locale {
locale: string;
dateFormat: string;
Pagination?: PaginationLocale;
DatePicker?: DatePickerLocale;
TimePicker?: Record<string, any>;
Expand Down
Loading