mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 11:58:10 +08:00
fix: 数据配置外部接口添加防抖处理,避免输入内容错乱
This commit is contained in:
parent
77360212e8
commit
7ea432922b
@ -21,6 +21,7 @@ import type {SchemaObject, SchemaCollection, SchemaApi} from 'amis';
|
||||
import type {Api} from 'amis';
|
||||
import type {FormControlProps} from 'amis-core';
|
||||
import type {ActionSchema} from 'amis';
|
||||
import debounce from 'lodash/debounce';
|
||||
|
||||
export type ApiObject = Api & {
|
||||
messages?: Record<
|
||||
@ -306,12 +307,9 @@ export default class APIControl extends React.Component<
|
||||
);
|
||||
}
|
||||
|
||||
@autobind
|
||||
handleSimpleInputChange(e: React.ChangeEvent<HTMLInputElement>) {
|
||||
const value = e.currentTarget.value;
|
||||
|
||||
handleSimpleInputChange = debounce((value: string) => {
|
||||
this.handleSubmit(value, 'input');
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
@autobind
|
||||
handleSubmit(values: SchemaApi, action?: 'input' | 'picker-submit') {
|
||||
@ -1036,7 +1034,9 @@ export default class APIControl extends React.Component<
|
||||
type="text"
|
||||
disabled={disabled}
|
||||
placeholder="http://"
|
||||
onChange={this.handleSimpleInputChange}
|
||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
|
||||
this.handleSimpleInputChange(e.currentTarget.value)
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{enablePickerMode ? this.renderPickerSchema() : null}
|
||||
|
@ -27,6 +27,7 @@ import type {Option} from 'amis';
|
||||
import {createObject, FormControlProps} from 'amis-core';
|
||||
import type {OptionValue} from 'amis-core';
|
||||
import type {SchemaApi} from 'amis';
|
||||
import debounce from 'lodash/debounce';
|
||||
|
||||
export type valueType = 'text' | 'boolean' | 'number';
|
||||
|
||||
@ -914,7 +915,7 @@ export default class OptionControl extends React.Component<
|
||||
body: [
|
||||
getSchemaTpl('sourceBindControl', {
|
||||
label: false,
|
||||
onChange: this.handleAPIChange
|
||||
onChange: debounce(this.handleAPIChange, 1000)
|
||||
})
|
||||
].concat(this.getFuncFieldSchema())
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user