fix: 修复input-image change 事件触发2次问题 (#4509)

Co-authored-by: liujintao03 <liujintao03@baidu.com>
This commit is contained in:
gooolh 2022-06-01 11:09:31 +08:00 committed by GitHub
parent 7d513f806b
commit 75f3a7bd69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -703,7 +703,7 @@ export default class ImageControl extends React.Component<
locked: false
},
() => {
this.onChange(!!this.resolve);
this.onChange(!!this.resolve, false);
if (this.resolve) {
this.resolve(
@ -773,7 +773,7 @@ export default class ImageControl extends React.Component<
});
}
async onChange(changeImmediately?: boolean) {
async onChange(changeImmediately?: boolean, changeEvent: boolean = true) {
const {
multiple,
onChange,
@ -807,9 +807,11 @@ export default class ImageControl extends React.Component<
: newValue;
}
const dispatcher = await this.dispatchEvent('change');
if (dispatcher?.prevented) {
return;
if (changeEvent) {
const dispatcher = await this.dispatchEvent('change');
if (dispatcher?.prevented) {
return;
}
}
onChange((this.emitValue = newValue || ''), undefined, changeImmediately);