mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-30 02:58:05 +08:00
Merge pull request #8317 from igrowp/fix-variable
fix: 数据配置外部接口添加防抖处理,避免输入内容错乱
This commit is contained in:
commit
ae13965365
@ -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