Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/OptionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,16 @@ const OptionList: React.ForwardRefRenderFunction<ReviseRefOptionListProps> = (_,
onKeyUp: () => {},
}));


const loadDataFun = React.useMemo(() => {
// should not pass `loadData` when expandedKeys is not changed
if (!searchValue && searchExpandedKeys?.length && !mergedExpandedKeys) {
return null
}

return searchValue ? null : (loadData as any)
}, [searchValue])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}, [searchValue])
}, [searchValue, searchExpandedKeys, mergedExpandedKeys]);


// ========================== Render ==========================
if (memoTreeData.length === 0) {
return (
Expand Down Expand Up @@ -237,7 +247,7 @@ const OptionList: React.ForwardRefRenderFunction<ReviseRefOptionListProps> = (_,
showIcon={showTreeIcon}
switcherIcon={switcherIcon}
showLine={treeLine}
loadData={searchValue ? null : (loadData as any)}
loadData={loadDataFun}
motion={treeMotion}
activeKey={activeKey}
// We handle keys by out instead tree self
Expand Down
Loading