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(WeekPicker):cross year select not selected at panel #751

Open
wants to merge 1 commit into
base: 2.7.x
Choose a base branch
from

Conversation

huiliangShen
Copy link

@huiliangShen huiliangShen commented Feb 6, 2024

fix antd@4.x bug 周选择时间控件选中跨年周时无高亮问题
It's cause isSameWeek function. for example: use 2024 first week, first date is 2023-12-31 (sunday) when local is US.
so when I click 2024-01-01, it's will be run the following code.
isSameWeek receive generateConfig, US, 2024-01-01 and 2023-12-31, following logic, it's will be return false, because the two date is not same year. we need to use generateConfig.locale.getWeekFirstDate function to calc date then judge is same year.

  const rowClassName = (date: DateType) =>
    classNames(rowPrefixCls, {
      [`${rowPrefixCls}-selected`]: isSameWeek(
        generateConfig,
        locale.locale,
        value,
        date,
      ),
    });
export function isSameWeek<DateType>(
  generateConfig: GenerateConfig<DateType>,
  locale: string,
  date1: NullableDateType<DateType>,
  date2: NullableDateType<DateType>,
) {
  const equal = isNullEqual(date1, date2);
  if (typeof equal === 'boolean') {
    return equal;
  }
  // const weekStartDate1 = generateConfig.locale.getWeekFirstDate(locale, date1!);
  // const weekStartDate2 = generateConfig.locale.getWeekFirstDate(locale, date2!);
  return (
    isSameYear(generateConfig, date1, date2) &&
    generateConfig.locale.getWeek(locale, date1!) === generateConfig.locale.getWeek(locale, date2!)
  );
}

Copy link

vercel bot commented Feb 6, 2024

Someone is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

codecov bot commented Feb 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (fd5fe22) 99.09% compared to head (bd3f096) 99.09%.

Additional details and impacted files
@@           Coverage Diff           @@
##            2.7.x     #751   +/-   ##
=======================================
  Coverage   99.09%   99.09%           
=======================================
  Files          47       47           
  Lines        2215     2217    +2     
  Branches      675      675           
=======================================
+ Hits         2195     2197    +2     
  Misses         18       18           
  Partials        2        2           

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

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.

1 participant