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

[DatePickRange]: 预设不支持 dayjs.utc #2113

Open
1 task done
vaynevayne opened this issue Aug 1, 2023 · 3 comments · May be fixed by #2114
Open
1 task done

[DatePickRange]: 预设不支持 dayjs.utc #2113

vaynevayne opened this issue Aug 1, 2023 · 3 comments · May be fixed by #2114

Comments

@vaynevayne
Copy link

vaynevayne commented Aug 1, 2023

arco 是错误的: https://codesandbox.io/s/loving-feynman-s8zclz?file=/demo.js
antd 是正确的: https://codesandbox.io/s/yu-she-fan-wei-antd-5-7-3-forked-tvx4d3?file=/demo.tsx

image
     {
          text: '上月',
          value: () => [
            dayjs.utc().subtract(1, 'month').startOf('month'),
            dayjs.utc().subtract(1, 'month').endOf('month'), 
          ],
        },

正确的结束时间应该是: 2023-07-31
image

但是 组件显示的结束时间是 2023-08-01
ps: 未使用 utcoffset相关 prop

Basic Info

  • Package Name And Version: @arco-design/web-react@2.51.0
  • Browser: chrome115.0.0.0
@vaynevayne vaynevayne changed the title [DatePickRange]: dayjs.utc 时间显示异常 [DatePickRange]: 预设不支持 dayjs.utc Aug 1, 2023
@vaynevayne
Copy link
Author

@yinkaihui

@vaynevayne
Copy link
Author

修改建议, 支持字符串类型的shortcut(其实你们shortcut 部分的代码已经支持了), 但是并不会生效是因为这里卡住了,

https://github.com/arco-design/arco-design/blob/main/components/DatePicker/picker-range.tsx#L656

getDayjsValue里面已经做了判断, isValidShortcut 是冗余的, 并且两者有冲突, 移除isValidShortcut判断即可https://github.com/arco-design/arco-design/blob/main/components/_util/dayjs.ts#L218

最后:

  // Callback when mouse entered the shortcuts
  function onMouseEnterShortcut(shortcut) {
    clearShortcutsTimer();
    shortcutEnterTimer.current = setTimeout(() => {
     //  if (isValidShortcut(shortcut)) {
        const nv = getDayjsValue(shortcut.value(), format, utcOffset, timezone) as Dayjs[];
        setShortcutsValue(nv);
        setFixedPageShowDates(nv);
      // } 
    }, 50);
  }

@vaynevayne vaynevayne linked a pull request Aug 1, 2023 that will close this issue
15 tasks
@PengJiyuan
Copy link
Member

小黑子

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 a pull request may close this issue.

2 participants