@@ -3,6 +3,7 @@ import { clsx } from 'clsx';
33import type { useBaseProps } from '@rc-component/select' ;
44import type { RefOptionListProps } from '@rc-component/select/lib/OptionList' ;
55import * as React from 'react' ;
6+ import useMemo from '@rc-component/util/lib/hooks/useMemo' ;
67import type { DefaultOptionType , LegacyKey , SingleValueType } from '../Cascader' ;
78import CascaderContext from '../context' ;
89import {
@@ -14,7 +15,6 @@ import {
1415 toPathValueStr ,
1516} from '../utils/commonUtil' ;
1617import { toPathOptions } from '../utils/treeUtil' ;
17- import CacheContent from './CacheContent' ;
1818import Column , { FIX_LABEL } from './Column' ;
1919import useActive from './useActive' ;
2020import useKeyboard from './useKeyboard' ;
@@ -137,14 +137,21 @@ const RawOptionList = React.forwardRef<RefOptionListProps, RawOptionListProps>((
137137 } ;
138138
139139 // ========================== Option ==========================
140- const mergedOptions = React . useMemo ( ( ) => {
140+ const filteredOptions = React . useMemo ( ( ) => {
141141 if ( searchValue ) {
142142 return searchOptions ;
143143 }
144144
145145 return options ;
146146 } , [ searchValue , searchOptions , options ] ) ;
147147
148+ // Update only when open or lockOptions
149+ const mergedOptions = useMemo (
150+ ( ) => filteredOptions ,
151+ [ open , lockOptions ] ,
152+ ( prev , next ) => ! ! next [ 0 ] && ! next [ 1 ] ,
153+ ) ;
154+
148155 // ========================== Column ==========================
149156 const optionColumns = React . useMemo ( ( ) => {
150157 const optionList = [ { options : mergedOptions } ] ;
@@ -248,17 +255,15 @@ const RawOptionList = React.forwardRef<RefOptionListProps, RawOptionListProps>((
248255
249256 // >>>>> Render
250257 return (
251- < CacheContent open = { open } lockOptions = { lockOptions } >
252- < div
253- className = { clsx ( `${ mergedPrefixCls } -menus` , {
254- [ `${ mergedPrefixCls } -menu-empty` ] : isEmpty ,
255- [ `${ mergedPrefixCls } -rtl` ] : rtl ,
256- } ) }
257- ref = { containerRef }
258- >
259- { columnNodes }
260- </ div >
261- </ CacheContent >
258+ < div
259+ className = { clsx ( `${ mergedPrefixCls } -menus` , {
260+ [ `${ mergedPrefixCls } -menu-empty` ] : isEmpty ,
261+ [ `${ mergedPrefixCls } -rtl` ] : rtl ,
262+ } ) }
263+ ref = { containerRef }
264+ >
265+ { columnNodes }
266+ </ div >
262267 ) ;
263268} ) ;
264269
0 commit comments