Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"classnames": "2.x",
"@rc-component/select": "~1.1.0",
"@rc-component/tree": "~1.0.1",
"@rc-component/util": "^1.2.1"
"@rc-component/util": "^1.3.0"
},
"devDependencies": {
"@rc-component/father-plugin": "^2.0.2",
Expand Down
10 changes: 4 additions & 6 deletions src/TreeSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import useId from '@rc-component/util/lib/hooks/useId';
import type { IconType } from '@rc-component/tree/lib/interface';
import type { ExpandAction } from '@rc-component/tree/lib/Tree';
import { conductCheck } from '@rc-component/tree/lib/utils/conductUtil';
import useMergedState from '@rc-component/util/lib/hooks/useMergedState';
import useControlledState from '@rc-component/util/lib/hooks/useControlledState';
import * as React from 'react';
import useCache from './hooks/useCache';
import useCheckedKeys from './hooks/useCheckedKeys';
Expand Down Expand Up @@ -224,7 +224,7 @@ const TreeSelect = React.forwardRef<BaseSelectRef, TreeSelectProps>((props, ref)
treeNodeFilterProp = 'value',
} = searchConfig;

const [internalValue, setInternalValue] = useMergedState(defaultValue, { value });
const [internalValue, setInternalValue] = useControlledState(defaultValue, value);

// `multiple` && `!treeCheckable` should be show all
const mergedShowCheckedStrategy = React.useMemo(() => {
Expand All @@ -249,10 +249,8 @@ const TreeSelect = React.forwardRef<BaseSelectRef, TreeSelectProps>((props, ref)
);

// =========================== Search ===========================
const [mergedSearchValue, setSearchValue] = useMergedState('', {
value: searchValue,
postState: search => search || '',
});
const [internalSearchValue, setSearchValue] = useControlledState('', searchValue);
const mergedSearchValue = internalSearchValue || '';

const onInternalSearch = searchText => {
setSearchValue(searchText);
Expand Down