Skip to content

Commit 83b315e

Browse files
committed
fix: Cache option for filter
1 parent 7ebd481 commit 83b315e

4 files changed

Lines changed: 8 additions & 5 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"test": "rc-test"
4444
},
4545
"dependencies": {
46-
"@rc-component/select": "~1.5.0",
46+
"@rc-component/select": "~1.5.2",
4747
"@rc-component/tree": "~1.2.0",
4848
"@rc-component/util": "^1.4.0",
4949
"clsx": "^2.1.1"

src/OptionList/CacheContent.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import * as React from 'react';
33
export interface CacheContentProps {
44
children?: React.ReactNode;
55
open?: boolean;
6+
lockOptions?: boolean;
67
}
78

89
const CacheContent = React.memo(
910
({ children }: CacheContentProps) => children as React.ReactElement,
10-
(_, next) => !next.open,
11+
(_, next) => !next.open && next.lockOptions,
1112
);
1213

1314
if (process.env.NODE_ENV !== 'production') {

src/OptionList/List.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export type RawOptionListProps = Pick<
2929
| 'direction'
3030
| 'open'
3131
| 'disabled'
32+
| 'lockOptions'
3233
>;
3334

3435
const RawOptionList = React.forwardRef<RefOptionListProps, RawOptionListProps>((props, ref) => {
@@ -41,6 +42,7 @@ const RawOptionList = React.forwardRef<RefOptionListProps, RawOptionListProps>((
4142
direction,
4243
open,
4344
disabled,
45+
lockOptions,
4446
} = props;
4547

4648
const containerRef = React.useRef<HTMLDivElement>(null);
@@ -246,7 +248,7 @@ const RawOptionList = React.forwardRef<RefOptionListProps, RawOptionListProps>((
246248

247249
// >>>>> Render
248250
return (
249-
<CacheContent open={open}>
251+
<CacheContent open={open} lockOptions={lockOptions}>
250252
<div
251253
className={clsx(`${mergedPrefixCls}-menus`, {
252254
[`${mergedPrefixCls}-menu-empty`]: isEmpty,

src/OptionList/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import * as React from 'react';
44
import RawOptionList from './List';
55

66
const RefOptionList = React.forwardRef<RefOptionListProps>((props, ref) => {
7-
const baseProps = useBaseProps();
7+
const { lockOptions, ...baseProps } = useBaseProps();
88

99
// >>>>> Render
10-
return <RawOptionList {...props} {...baseProps} ref={ref} />;
10+
return <RawOptionList {...props} {...baseProps} lockOptions={lockOptions} ref={ref} />;
1111
});
1212

1313
export default RefOptionList;

0 commit comments

Comments
 (0)