fix:修复select组件在非可多选情况下,配置checkAll:true属性导致无法选中值的问题 (#4393)

Co-authored-by: ”jiatianqi“ <”jiatianqi@baidu.com“>
This commit is contained in:
Ma ke 2022-05-19 15:51:30 +08:00 committed by GitHub
parent da82f8374a
commit 6a1e4fa595
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 7 deletions

View File

@ -1124,10 +1124,8 @@ export class Select extends React.Component<SelectProps, SelectState> {
isOpen={this.state.isOpen} isOpen={this.state.isOpen}
inputValue={inputValue} inputValue={inputValue}
onChange={ onChange={
/*展示 Checkbox 的时候,会出发多次 onChange 原因待查*/ multiple || /*展示 Checkbox 的时候,会出发多次 onChange 原因待查*/
checkAll multiple ? noop : this.handleChange
? noop
: this.handleChange
} }
onStateChange={this.handleStateChange} onStateChange={this.handleStateChange}
itemToString={item => (item ? `${item[labelField]}` : '')} itemToString={item => (item ? `${item[labelField]}` : '')}

View File

@ -85,6 +85,18 @@ export interface SelectControlSchema extends FormOptionsControl {
* API * API
*/ */
searchApi?: SchemaApi; searchApi?: SchemaApi;
/**
*
*/
checkAll?: boolean;
/**
*
*/
defaultCheckAll?: boolean;
/**
*
*/
checkAllLabel?: string;
} }
export interface SelectProps extends OptionsControlProps { export interface SelectProps extends OptionsControlProps {
@ -412,9 +424,7 @@ export default class SelectControl extends React.Component<SelectProps, any> {
onFocus={(e: any) => this.dispatchEvent('focus', e)} onFocus={(e: any) => this.dispatchEvent('focus', e)}
onAdd={() => this.dispatchEvent('add')} onAdd={() => this.dispatchEvent('add')}
onEdit={(item: any) => this.dispatchEvent('edit', item)} onEdit={(item: any) => this.dispatchEvent('edit', item)}
onDelete={(item: any) => onDelete={(item: any) => this.dispatchEvent('delete', item)}
this.dispatchEvent('delete', item)
}
loading={loading} loading={loading}
noResultsText={noResultsText} noResultsText={noResultsText}
renderMenu={menuTpl ? this.renderMenu : undefined} renderMenu={menuTpl ? this.renderMenu : undefined}