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: Slider bug (#2171) #2186

Merged
merged 1 commit into from May 15, 2024
Merged

fix: Slider bug (#2171) #2186

merged 1 commit into from May 15, 2024

Conversation

zzc6332
Copy link
Contributor

@zzc6332 zzc6332 commented Apr 21, 2024

中文模板 / Chinese Template

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Test Case
  • TypeScript definition update
  • Document improve
  • CI/CD improve
  • Branch sync
  • Other, please describe:

PR description

Fixes #2171

  • Bug 1:
    • Cause: In packages\semi-ui\slider\index.tsx, the onHandleDown method (line 206) adds event listeners for the window’s mouseup event and the body’s touchmove event. However, in onHandleUpBefore (line 261), the mouseup event for the body is removed, but the touchmove event listener for the body is not, resulting in these two events remaining in a listening state.
    • Fix: Since a custom this._addEventListener is used when binding event listeners, which records the listened events and returns a function to cancel the listener, the return values should be collected in onHandleDown. Then, in onHandleUpBefore, all these listeners added during onHandleDown should be removed together to ensure that all listeners added during onHandleDown are removed.
  • Bug 2:
    • Cause: The handle element has an onMouseUp listener bound, which triggers this.foundation.onHandleUp (lines 362, 423, 479). However, this.foundation.onHandleUp has already been bound as a callback for the window’s mouseup event in onHandleUpBefore (line 261), so there is no need to listen for the mouseup event on the handle element. This can cause the mouseup event triggered on the handle of another Slider component during dragging to override the callback for the window’s mouseup event, resulting in the component’s isDrag state remaining true.
    • Fix: Remove the onMouseUp listener from the handle element.

Changelog

🇨🇳 Chinese

  • Fix: Slider 在特殊场景下触发事件时机异常的问题。

🇺🇸 English

  • Fix: Slider triggers events at abnormal timing in special scenarios

Checklist

  • Test or no need
  • Document or no need
  • Changelog or no need

Other

  • Skip Changelog

Additional information

Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 37715c8:

Sandbox Source
pr-story Configuration

@DaiQiangReal DaiQiangReal merged commit 00e322d into DouyinFE:release May 15, 2024
1 check passed
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.

None yet

2 participants