mirror of
https://github.com/apache/superset.git
synced 2026-04-23 01:55:09 +00:00
fix: Ignore case and special keys when searching (#16706)
This commit is contained in:
committed by
GitHub
parent
b0ac5d1625
commit
adc3d24c21
@@ -20,6 +20,7 @@ import React, {
|
||||
ReactElement,
|
||||
ReactNode,
|
||||
RefObject,
|
||||
KeyboardEvent,
|
||||
UIEvent,
|
||||
useEffect,
|
||||
useMemo,
|
||||
@@ -333,13 +334,18 @@ const Select = ({
|
||||
|
||||
const handleData = (data: OptionsType) => {
|
||||
if (data && Array.isArray(data) && data.length) {
|
||||
const dataValues = new Set();
|
||||
data.forEach(option =>
|
||||
dataValues.add(String(option.value).toLocaleLowerCase()),
|
||||
);
|
||||
|
||||
// merges with existing and creates unique options
|
||||
setSelectOptions(prevOptions => [
|
||||
...prevOptions,
|
||||
...data.filter(
|
||||
newOpt =>
|
||||
!prevOptions.find(prevOpt => prevOpt.value === newOpt.value),
|
||||
...prevOptions.filter(
|
||||
previousOption =>
|
||||
!dataValues.has(String(previousOption.value).toLocaleLowerCase()),
|
||||
),
|
||||
...data,
|
||||
]);
|
||||
}
|
||||
};
|
||||
@@ -459,8 +465,8 @@ const Select = ({
|
||||
return error ? <Error error={error} /> : originNode;
|
||||
};
|
||||
|
||||
const onInputKeyDown = () => {
|
||||
if (isAsync && !isTyping) {
|
||||
const onInputKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
|
||||
if (event.key.length === 1 && isAsync && !isTyping) {
|
||||
setIsTyping(true);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user