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

CalendarPicker为什么只能向后滚动, 不能向前滚动 #6412

Open
cheng-xiaofeng opened this issue Oct 26, 2023 · 14 comments
Open

CalendarPicker为什么只能向后滚动, 不能向前滚动 #6412

cheng-xiaofeng opened this issue Oct 26, 2023 · 14 comments
Assignees

Comments

@cheng-xiaofeng
Copy link

Version of antd-mobile

5.33.0

What is this feature about?

比如现在是2023年10月, 我用ref?.current?.jumpTo({ year: 2023, month: 11 })跳到了11月份, 我想滚动到10月份, 但没法回到10月份

@zombieJ
Copy link
Member

zombieJ commented Oct 26, 2023

给个 codesandbox 看看?

@cheng-xiaofeng
Copy link
Author

给个 codesandbox 看看?
image

https://mobile.ant.design/zh/components/calendar-picker/calendar-picker
这里,向上滚动就滚不动

@zombieJ
Copy link
Member

zombieJ commented Oct 26, 2023

嗯,jumpTo 还隐含了设置起始时间的约定。这个的确不是很符合直觉。

@Yueyanc
Copy link

Yueyanc commented Nov 3, 2023

@zombieJ 还有就是抽屉出现时,默认在min处,而不是当前选中项,如果我的min设置到一年前,我每次都需要手动去滚动

@hanwenbo
Copy link

hanwenbo commented Nov 9, 2023

@zombieJ 是的这里确实是个bug

@liqiuqiui
Copy link
Contributor

@zombieJ 还有就是抽屉出现时,默认在min处,而不是当前选中项,如果我的min设置到一年前,我每次都需要手动去滚动

+1,默认打开的时候没有滚动到当前选中的位置在使用上感觉挺不友好的

@angleneo
Copy link

这个bug还没有修复吗

@bravepg
Copy link
Contributor

bravepg commented Jan 15, 2024

@angleneo @cheng-xiaofeng @liqiuqiui 你们在使用的时候,会期望这个组件可以无限滚动么?现在其实是限制了 6 个月的选择。

@angleneo
Copy link

angleneo commented Jan 15, 2024 via email

@liqiuqiui

This comment was marked as outdated.

@Yueyanc
Copy link

Yueyanc commented Jan 16, 2024

@angleneo @cheng-xiaofeng @liqiuqiui 你们在使用的时候,会期望这个组件可以无限滚动么?现在其实是限制了 6 个月的选择。

@angleneo @cheng-xiaofeng @liqiuqiui 你们在使用的时候,会期望这个组件可以无限滚动么?现在其实是限制了 6 个月的选择。

这是默认的min,max限制没啥问题,问题出在每次打开这个picker显示的是min所在的日期,而不是当前选中项所在的日期

#6521

@lisatisfy
Copy link

@angleneo @cheng-xiaofeng @liqiuqiui 你们在使用的时候,会期望这个组件可以无限滚动么?现在其实是限制了 6 个月的选择。

@angleneo @cheng-xiaofeng @liqiuqiui 你们在使用的时候,会期望这个组件可以无限滚动么?现在其实是限制了 6 个月的选择。

这是默认的min,max限制没啥问题,问题出在每次打开这个picker显示的是min所在的日期,而不是当前选中项所在的日期

#6521

同样的有这个困扰。如果设置了min,每次打开这个picker显示的是min所在的日期。

@zk2611
Copy link

zk2611 commented May 16, 2024

@angleneo @cheng-xiaofeng @liqiuqiui 你们在使用的时候,会期望这个组件可以无限滚动么?现在其实是限制了 6 个月的选择。

期望默认无限滚动,可配制 min、max,而且期望首次打开的时候,如果没有传入 value、defaultValue,则默认展示当前月,而非展示 min 所在月 🙏🙏🙏

@luopeihai
Copy link

luopeihai commented Jun 18, 2024

监听日期选择框,手动滚动到对应默认选中的日期未知

 // 控制日期选择
   const [visibleCalendarPicker, setVisibleCalendarPicker] = useState(false)

  useEffect(() => {
    if (visibleCalendarPicker) {
      const timeout = setTimeout(() => {
        const elementCalendar = document.querySelector<HTMLDivElement>('.adm-calendar-picker-view-body');
        const element = document.querySelector<HTMLDivElement>('.adm-calendar-picker-view-cell-selected-begin');
        if (elementCalendar && element) {
          elementCalendar.scrollTop = element.offsetTop - 200;
        }
      }, 100);
      return () => clearTimeout(timeout);
    }
  }, [visibleCalendarPicker]);

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

No branches or pull requests

10 participants