diff --git a/src/hooks/useSearchConfig.ts b/src/hooks/useSearchConfig.ts
index e9889ad6..b7b6da80 100644
--- a/src/hooks/useSearchConfig.ts
+++ b/src/hooks/useSearchConfig.ts
@@ -22,7 +22,7 @@ export default function useSearchConfig(showSearch?: CascaderProps['showSearch']
}
if ((searchConfig.limit as number) <= 0) {
- delete searchConfig.limit;
+ searchConfig.limit = false;
if (process.env.NODE_ENV !== 'production') {
warning(false, "'limit' of showSearch should be positive number or false.");
diff --git a/tests/search.limit.spec.tsx b/tests/search.limit.spec.tsx
new file mode 100644
index 00000000..2ebfd097
--- /dev/null
+++ b/tests/search.limit.spec.tsx
@@ -0,0 +1,76 @@
+import React from 'react';
+import Cascader from '../src';
+import type { ReactWrapper } from './enzyme';
+import { mount } from './enzyme';
+
+describe('Cascader.Search', () => {
+ function doSearch(wrapper: ReactWrapper, search: string) {
+ wrapper.find('input').simulate('change', {
+ target: {
+ value: search,
+ },
+ });
+ }
+ const options = [
+ {
+ children: [] as any[],
+ isParent: true,
+ label: 'Asia',
+ value: 'Asia',
+ },
+ ];
+ for (let i = 0; i < 100; i++) {
+ options[0].children.push({
+ label: 'label' + i,
+ value: 'value' + i,
+ });
+ }
+
+ it('limit', () => {
+ const wrapper = mount(
+ ,
+ );
+
+ doSearch(wrapper, 'as');
+ const itemList = wrapper.find('div.rc-cascader-menu-item-content');
+ expect(itemList).toHaveLength(100);
+ });
+
+ it('limit', () => {
+ const wrapper = mount(
+ ,
+ );
+
+ doSearch(wrapper, 'as');
+ const itemList = wrapper.find('div.rc-cascader-menu-item-content');
+ expect(itemList).toHaveLength(100);
+ });
+
+ it('limit', () => {
+ const wrapper = mount(
+ ,
+ );
+
+ doSearch(wrapper, 'as');
+ const itemList = wrapper.find('div.rc-cascader-menu-item-content');
+ expect(itemList).toHaveLength(20);
+ });
+});