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: onAfterChange should not trigger when click on track #952

Merged
merged 4 commits into from Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/examples/debug.tsx
Expand Up @@ -52,6 +52,9 @@ export default () => {
console.log('Change:', nextValues);
// setValue(nextValues as any);
}}
onAfterChange={(v) => {
console.log('AfterChange:', v);
}}
// value={value}

min={0}
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/marks.tsx
Expand Up @@ -25,7 +25,7 @@ export default () => (
<div>
<div style={style}>
<p>Slider with marks, `step=null`</p>
<Slider min={-10} marks={marks} step={null} onChange={log} defaultValue={20} />
<Slider min={-10} marks={marks} step={null} onChange={log} defaultValue={20} onAfterChange={(v) => console.log('AfterChange:', v)} />
</div>

<div style={style}>
Expand Down
1 change: 0 additions & 1 deletion src/Slider.tsx
Expand Up @@ -329,7 +329,6 @@ const Slider = React.forwardRef((props: SliderProps, ref: React.Ref<SliderRef>)

onBeforeChange?.(getTriggerValue(cloneNextValues));
triggerChange(cloneNextValues);
onAfterChange?.(getTriggerValue(cloneNextValues));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥 onBeforeChange 可以有, onAfterChange不能?

Copy link
Member Author

@MadCcc MadCcc Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onAfterChange 必须对应到 mouseup 事件上,现在允许拖拽之后 change 并不代表一定会触发 afterChange

if (e) {
onStartDrag(e, valueIndex, cloneNextValues);
}
Expand Down