react-component / react-component/picker
TimePicker panel will keep scrolling after select a time.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 304
- Forks
- 345
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 7
Description
i found the code below in useScrollTo.ts seemed to be buggy. After selecting a time from the time panel, the panel ul will scroll to the target li position. But when the target li is reaching top, the scrolling is not stopped, causing the scroll event could not be triggered on mouse-wheel scrolling.
// Break if dist get larger, which means user is scrolling
if (scrollDistRef.current !== null && scrollDistRef.current < dist) {
stopScroll();
return;
}
scrollDistRef.current = dist;
When the scenario above happens, the scrollDistRef.current is always equal to dist. So the stopScroll will be never called.
As I observed, the issue only happened on older browser like Chrome 89 in my case and did not occur on latest Chrome. In the latest Chrome, the scroll event can be fired even if the scrolling is not stopped.
I tried to changed the termimal condition as below, the scrolling is stopped and can be scrolled manually again:
if (scrollDistRef.current !== null && (scrollDistRef.current < dist || Math.abs(scrollDistRef.current - dist) < Number.EPSILON)) {
stopScroll();
return;
}
That is, to stop scrolling when scrollDistRef and dist is equal (dist does not change anymore).
Not sure if anyone got the same issue.
The antd version is 5.15.1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in useScrollTo.ts and inspect the scroll-distance termination condition described in the issue. Reproduce the TimePicker behavior in an older browser such as Chrome 89, then verify that selecting a time stops scrolling when the distance no longer changes and that mouse-wheel scrolling triggers normally afterward.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100