diff --git a/components/menu/OverrideContext.tsx b/components/menu/OverrideContext.tsx index bec81a456b42..f8b9720379ce 100644 --- a/components/menu/OverrideContext.tsx +++ b/components/menu/OverrideContext.tsx @@ -1,6 +1,7 @@ import * as React from 'react'; import { NoCompactStyle } from '../space/Compact'; import type { MenuProps } from './menu'; +import { supportNodeRef } from 'rc-util'; // Used for Dropdown only export interface OverrideContextProps { @@ -36,7 +37,11 @@ export const OverrideProvider = React.forwardRef< return ( - {React.cloneElement(children as React.ReactElement, { ref })} + + {supportNodeRef(children) + ? React.cloneElement(children as React.ReactElement, { ref }) + : children} + ); }); diff --git a/components/table/__tests__/Table.filter.test.tsx b/components/table/__tests__/Table.filter.test.tsx index 129f1d9c4761..df1ffe210589 100644 --- a/components/table/__tests__/Table.filter.test.tsx +++ b/components/table/__tests__/Table.filter.test.tsx @@ -2834,4 +2834,24 @@ describe('Table.filter', () => { true, ); }); + + it('should not crash when filterDropdown is boolean', () => { + const tableProps = { + key: 'stabletable', + rowKey: 'name', + dataSource: [], + columns: [ + { + title: 'Name', + dataIndex: 'name', + filterDropdown: true, + }, + ], + }; + + const { container } = render(createTable(tableProps)); + + // User opens filter Dropdown. + fireEvent.click(container.querySelector('.ant-dropdown-trigger.ant-table-filter-trigger')!); + }); }); diff --git a/package.json b/package.json index 7ae4fd84bb03..33487b37dc7e 100644 --- a/package.json +++ b/package.json @@ -154,7 +154,7 @@ "rc-tree": "~5.7.6", "rc-tree-select": "~5.11.0", "rc-upload": "~4.3.0", - "rc-util": "^5.32.0", + "rc-util": "^5.37.0", "scroll-into-view-if-needed": "^3.0.3", "throttle-debounce": "^5.0.0" },