Skip to content

Commit

Permalink
feat: deprecate onAfterChange for onChangeComplete (ant-design#46182)
Browse files Browse the repository at this point in the history
  • Loading branch information
MadCcc authored Nov 30, 2023
1 parent c4b8c9d commit 0f7f0cc
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 12 deletions.
6 changes: 3 additions & 3 deletions components/slider/__tests__/type.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('Slider.typescript', () => {
const value = 0;
const onChange = (v: number) => v;
const result = (
<Slider defaultValue={value} value={value} onChange={onChange} onAfterChange={onChange} />
<Slider defaultValue={value} value={value} onChange={onChange} onChangeComplete={onChange} />
);
expect(result).toBeTruthy();
});
Expand All @@ -20,7 +20,7 @@ describe('Slider.typescript', () => {
defaultValue={value}
value={value}
onChange={onChange}
onAfterChange={onChange}
onChangeComplete={onChange}
/>
);
expect(result).toBeTruthy();
Expand All @@ -34,7 +34,7 @@ describe('Slider.typescript', () => {
defaultValue={value}
value={value}
onChange={onChange}
onAfterChange={onChange}
onChangeComplete={onChange}
step={null}
/>
);
Expand Down
4 changes: 2 additions & 2 deletions components/slider/demo/event.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## zh-CN

当 Slider 的值发生改变时,会触发 `onChange` 事件,并把改变后的值作为参数传入。在 `onmouseup` 时,会触发 `onAfterChange` 事件,并把当前值作为参数传入。
当 Slider 的值发生改变时,会触发 `onChange` 事件,并把改变后的值作为参数传入。在 `mouseup` 或者 `keyup` 时,会触发 `onChangeComplete` 事件,并把当前值作为参数传入。

## en-US

The `onChange` callback function will fire when the user changes the slider's value. The `onAfterChange` callback function will fire when `onmouseup` fired.
The `onChange` callback function will fire when the user changes the slider's value. The `onChangeComplete` callback function will fire when `mouseup` or `keyup` fired.
8 changes: 4 additions & 4 deletions components/slider/demo/event.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ const onChange = (value: number | number[]) => {
console.log('onChange: ', value);
};

const onAfterChange = (value: number | number[]) => {
console.log('onAfterChange: ', value);
const onChangeComplete = (value: number | number[]) => {
console.log('onChangeComplete: ', value);
};

const App: React.FC = () => (
<>
<Slider defaultValue={30} onChange={onChange} onAfterChange={onAfterChange} />
<Slider defaultValue={30} onChange={onChange} onChangeComplete={onChangeComplete} />
<Slider
range
step={10}
defaultValue={[20, 50]}
onChange={onChange}
onAfterChange={onAfterChange}
onChangeComplete={onChangeComplete}
/>
</>
);
Expand Down
2 changes: 1 addition & 1 deletion components/slider/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Common props ref:[Common props](/docs/react/common-props)
| tooltip | The tooltip relate props | [tooltip](#tooltip) | - | 4.23.0 |
| value | The value of slider. When `range` is false, use number, otherwise, use \[number, number] | number \| \[number, number] | - | |
| vertical | If true, the slider will be vertical | boolean | false | |
| onAfterChange | Fire when onmouseup is fired | (value) => void | - | |
| onChangeComplete | Fire when `mouseup` or `keyup` is fired | (value) => void | - | |
| onChange | Callback function that is fired when the user changes the slider's value | (value) => void | - | |

### `styles``classNames` 属性
Expand Down
4 changes: 4 additions & 0 deletions components/slider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ export interface SliderSingleProps extends SliderBaseProps {
value?: number;
defaultValue?: number;
onChange?: (value: number) => void;
/** @deprecated Please use `onChangeComplete` instead */
onAfterChange?: (value: number) => void;
onChangeComplete?: (value: number) => void;
/** @deprecated Please use `styles.handle` instead */
handleStyle?: React.CSSProperties;
/** @deprecated Please use `styles.track` instead */
Expand All @@ -95,7 +97,9 @@ export interface SliderRangeProps extends SliderBaseProps {
value?: number[];
defaultValue?: number[];
onChange?: (value: number[]) => void;
/** @deprecated Please use `onChangeComplete` instead */
onAfterChange?: (value: number[]) => void;
onChangeComplete?: (value: number[]) => void;
/** @deprecated Please use `styles.handle` instead */
handleStyle?: React.CSSProperties[];
/** @deprecated Please use `styles.track` instead */
Expand Down
2 changes: 1 addition & 1 deletion components/slider/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ demo:
| tooltip | 设置 Tooltip 相关属性 | [tooltip](#tooltip) | - | 4.23.0 |
| value | 设置当前取值。当 `range` 为 false 时,使用 number,否则用 \[number, number] | number \| \[number, number] | - | |
| vertical | 值为 true 时,Slider 为垂直方向 | boolean | false | |
| onAfterChange |`onmouseup` 触发时机一致,把当前值作为参数传入 | (value) => void | - | |
| onChangeComplete |`mouseup``keyup` 触发时机一致,把当前值作为参数传入 | (value) => void | - | |
| onChange | 当 Slider 的值发生改变时,会触发 onChange 事件,并把改变后的值作为参数传入 | (value) => void | - | |

### `styles``classNames` 属性
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
"rc-resize-observer": "^1.4.0",
"rc-segmented": "~2.2.2",
"rc-select": "~14.10.0",
"rc-slider": "~10.4.0",
"rc-slider": "~10.5.0",
"rc-steps": "~6.0.1",
"rc-switch": "~4.1.0",
"rc-table": "~7.36.0",
Expand Down

0 comments on commit 0f7f0cc

Please sign in to comment.