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

CalendarPickerView 相关组件设置了 min 属性后 jumpTo jumpToToday 等方法不生效 #6518

Open
hubingkang opened this issue Jan 9, 2024 · 4 comments
Labels

Comments

@hubingkang
Copy link

Version of antd-mobile

5.30.0

Operating system and its version

No response

Browser and its version

No response

Sandbox to reproduce

https://codesandbox.io/p/sandbox/vibrant-jasper-g7yz6n?file=%2Fapp.tsx%3A18%2C18

What happened?

CalendarPickerView 相关组件设置了 min 属性后 jumpTo jumpToToday 等方法不生效

复现链接:https://codesandbox.io/p/sandbox/vibrant-jasper-g7yz6n?file=%2Fapp.tsx%3A18%2C18

Relevant log output

No response

@hubingkang hubingkang added the bug label Jan 9, 2024
@day-xue
Copy link
Contributor

day-xue commented Jan 10, 2024

确实是这样

@Jarryxin
Copy link
Contributor

Jarryxin commented Jan 10, 2024

预期是怎样的,调用 jumpTo jumpToToday 方法时,第一个渲染日期月份就是 jumpTo 传参的月份/当天的日期月份,原先展示的第一个就看不到了。
如 当前日期是 2024-01,jumpTo(2025-01) 就看不到 2024-01了。
代码中有下边的逻辑:

  const minDay = useMemo(
    () => (props.min ? dayjs(props.min) : current),
    [props.min, current]
  )

如果设置了最小值,那开始渲染的日期就是从最小值日期开始,所以 jumpTo jumpToToday 等方法不生效。
#6425

@day-xue
Copy link
Contributor

day-xue commented Jan 11, 2024

感觉可以重写一下

@hubingkang
Copy link
Author

很多业务场景会有最大最小值,定位到当前选中的日期,这样体验会好很多。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants