mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-01 18:52:20 +08:00
fix: search field should be searched based on the translated text (#5572)
This commit is contained in:
parent
17582e9351
commit
fdf8aa6f44
@ -11,6 +11,7 @@ import { uid } from '@formily/shared';
|
||||
import { Divider, Empty, Input, MenuProps } from 'antd';
|
||||
import React, { useEffect, useMemo, useState, useRef } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useCompile } from '../../../';
|
||||
|
||||
function getPrefixAndCompare(a, b) {
|
||||
const prefixA = a.replace(/-displayCollectionFields$/, '');
|
||||
@ -100,6 +101,7 @@ export const useMenuSearch = (props: { children: any[]; showType?: boolean; hide
|
||||
const { children, showType, hideSearch, name } = props;
|
||||
const items = children?.concat?.() || [];
|
||||
const [searchValue, setSearchValue] = useState(null);
|
||||
const compile = useCompile();
|
||||
|
||||
// 处理搜索逻辑
|
||||
const limitedSearchedItems = useMemo(() => {
|
||||
@ -107,13 +109,14 @@ export const useMenuSearch = (props: { children: any[]; showType?: boolean; hide
|
||||
return items;
|
||||
}
|
||||
const lowerSearchValue = searchValue.toLocaleLowerCase();
|
||||
return items.filter(
|
||||
(item) =>
|
||||
return items.filter((item) => {
|
||||
return (
|
||||
(item.title || item.label) &&
|
||||
String(item.title || item.label)
|
||||
String(compile(item.title || item.label))
|
||||
.toLocaleLowerCase()
|
||||
.includes(lowerSearchValue),
|
||||
);
|
||||
.includes(lowerSearchValue)
|
||||
);
|
||||
});
|
||||
}, [searchValue, items]);
|
||||
|
||||
// 最终结果项
|
||||
|
Loading…
x
Reference in New Issue
Block a user