fix site search fuzzy

This commit is contained in:
Rizky 2023-10-29 07:57:26 +07:00
parent 285f7e5351
commit b4608a7e33
2 changed files with 8 additions and 5 deletions

View File

@ -370,8 +370,11 @@ export const EdSiteTree = ({
dragPreviewRender={() => <></>} dragPreviewRender={() => <></>}
classes={{ classes={{
root: cx( root: cx(
"flex flex-1 items-stretch overflow-auto", "flex overflow-auto",
search ? "flex-row" : "flex-col", search
? "flex-row items-start flex-wrap"
: "flex-col items-stretch flex-1 ",
!search && !search &&
css` css`
flex-wrap: nowrap; flex-wrap: nowrap;
@ -386,7 +389,7 @@ export const EdSiteTree = ({
} }
` `
), ),
container: "flex flex-row flex-wrap pb-2", container: cx(!search && "flex flex-row flex-wrap pb-2"),
}} }}
render={render} render={render}
/> />

View File

@ -13,10 +13,10 @@ export const fuzzy = <T extends object>(
if (idxs && info) { if (idxs && info) {
const result = [] as T[]; const result = [] as T[];
let i = 0; let ri = 0;
for (const idx of idxs) { for (const idx of idxs) {
const item = array[idx]; const item = array[idx];
const range = [...info.ranges[i]]; const range = [...info.ranges[ri++]];
const val = item[field] as string; const val = item[field] as string;
let cur = range.shift(); let cur = range.shift();