fix: inputRange更换事件名称 (#5470)

This commit is contained in:
kano 2022-09-30 17:56:05 +08:00 committed by GitHub
parent 19bfac7493
commit c4e043c735
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View File

@ -133,7 +133,8 @@ class HandleItem extends React.Component<HandleItemProps, HandleItemState> {
this.setState({
isDrag: false
});
this.props.onAfterChange();
const {onAfterChange} = this.props;
onAfterChange && onAfterChange();
window.removeEventListener('mousemove', this.onMouseMove);
window.removeEventListener('mouseup', this.onMouseUp);
}
@ -291,7 +292,8 @@ export class Range extends React.Component<RangeItemProps, any> {
*/
@autobind
updateValue(value: FormatValue) {
this.props.updateValue(value);
const {onChange} = this.props;
onChange && onChange(value);
}
/**

View File

@ -239,7 +239,7 @@ export interface DefaultProps {
export interface RangeItemProps extends RangeProps {
value: FormatValue;
updateValue: (value: Value) => void;
onChange: (value: Value) => void;
onAfterChange: () => void;
}
@ -298,7 +298,7 @@ export class Input extends React.Component<RangeItemProps, any> {
const {multiple, value: originValue, type, min} = this.props;
const _value = this.getValue(value, type);
this.props.updateValue(
this.props.onChange(
multiple
? {...(originValue as MultipleValue), [type]: _value}
: value ?? min
@ -314,7 +314,7 @@ export class Input extends React.Component<RangeItemProps, any> {
const {multiple, value: originValue, type} = this.props;
const _value = this.getValue(value, type);
this.props.updateValue(
this.props.onChange(
multiple ? {...(originValue as MultipleValue), [type]: _value} : value
);
}
@ -547,11 +547,11 @@ export default class RangeControl extends React.PureComponent<
}
/**
* value变换 -> updateValue
* value变换 -> onChange
* @param value
*/
@autobind
async updateValue(value: FormatValue) {
async onChange(value: FormatValue) {
this.setState({value: this.getValue(value)});
const {onChange, data, dispatchEvent} = this.props;
const result = this.getFormatValue(value);
@ -604,7 +604,7 @@ export default class RangeControl extends React.PureComponent<
const props: RangeItemProps = {
...this.props,
value,
updateValue: this.updateValue,
onChange: this.onChange,
onAfterChange: this.onAfterChange
};