Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -43,7 +43,7 @@
"test": "rc-test"
},
"dependencies": {
"@rc-component/select": "~1.5.0",
"@rc-component/select": "~1.5.2",
"@rc-component/tree": "~1.2.0",
"@rc-component/util": "^1.4.0",
"clsx": "^2.1.1"
Expand Down
3 changes: 2 additions & 1 deletion src/OptionList/CacheContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import * as React from 'react';
export interface CacheContentProps {
children?: React.ReactNode;
open?: boolean;
lockOptions?: boolean;
}

const CacheContent = React.memo(
({ children }: CacheContentProps) => children as React.ReactElement,
(_, next) => !next.open,
(_, next) => !next.open && next.lockOptions,
);

if (process.env.NODE_ENV !== 'production') {
Expand Down
4 changes: 3 additions & 1 deletion src/OptionList/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export type RawOptionListProps = Pick<
| 'direction'
| 'open'
| 'disabled'
| 'lockOptions'
>;

const RawOptionList = React.forwardRef<RefOptionListProps, RawOptionListProps>((props, ref) => {
Expand All @@ -41,6 +42,7 @@ const RawOptionList = React.forwardRef<RefOptionListProps, RawOptionListProps>((
direction,
open,
disabled,
lockOptions,
} = props;

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

// >>>>> Render
return (
<CacheContent open={open}>
<CacheContent open={open} lockOptions={lockOptions}>
<div
className={clsx(`${mergedPrefixCls}-menus`, {
[`${mergedPrefixCls}-menu-empty`]: isEmpty,
Expand Down
4 changes: 2 additions & 2 deletions src/OptionList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import * as React from 'react';
import RawOptionList from './List';

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

// >>>>> Render
return <RawOptionList {...props} {...baseProps} ref={ref} />;
return <RawOptionList {...props} {...baseProps} lockOptions={lockOptions} ref={ref} />;
});

export default RefOptionList;
Loading