mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
fix: inputText autoComplete 输入内容导致选项重复问题 (#5272)
* fix: inputText autoComplete 输入内容导致选项重复问题 * 修改
This commit is contained in:
parent
1eb03d6a79
commit
92d08b0ae4
@ -1,14 +1,20 @@
|
||||
import {OptionValue, Option} from '../types';
|
||||
import {isObject} from './helper';
|
||||
import {isEqual} from 'lodash';
|
||||
|
||||
export function matchOptionValue(
|
||||
a: OptionValue,
|
||||
b: Option,
|
||||
valueField: string = 'value'
|
||||
) {
|
||||
return isObject(a)
|
||||
? a === b[valueField || 'value']
|
||||
: String(b[valueField || 'value']) === String(a);
|
||||
// a 可能为 Option, 此时需要取其value
|
||||
const aValue =
|
||||
isObject(a) && a && (a as Option).hasOwnProperty(valueField)
|
||||
? (a as Option)[valueField]
|
||||
: a;
|
||||
return isObject(aValue)
|
||||
? isEqual(aValue, b[valueField || 'value'])
|
||||
: String(b[valueField || 'value']) === String(aValue);
|
||||
}
|
||||
|
||||
export function optionValueCompare(
|
||||
|
Loading…
Reference in New Issue
Block a user