From 71b19b9377ea94527bdb32d7e293a58bf0cedce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=89=8D=E7=AB=AF=E7=BB=83=E4=B9=A0=E4=B8=A4=E5=B9=B4?= =?UTF-8?q?=E5=8D=8A?= <35835206+Tesla0916@users.noreply.github.com> Date: Wed, 19 Oct 2022 15:41:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dopen=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E5=86=B2=E7=AA=81=E7=9A=84=E9=97=AE=E9=A2=98=20close=20#1736?= =?UTF-8?q?=20(#1831)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 修复open属性冲突的问题 * test: 增加export组件dropdown测试用例 Co-authored-by: chengqu --- .../__tests__/bugs/issue-1736-spec.tsx | 46 +++++++++++++++++++ .../s2-react/src/components/export/index.tsx | 7 ++- s2-site/docs/api/components/export.zh.md | 1 + 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 packages/s2-react/__tests__/bugs/issue-1736-spec.tsx diff --git a/packages/s2-react/__tests__/bugs/issue-1736-spec.tsx b/packages/s2-react/__tests__/bugs/issue-1736-spec.tsx new file mode 100644 index 0000000000..06b5fb9a3e --- /dev/null +++ b/packages/s2-react/__tests__/bugs/issue-1736-spec.tsx @@ -0,0 +1,46 @@ +/** + * @description spec for issue #1736 + * https://github.com/antvis/S2/issues/1736 + * Export dropdown visible state error + */ +import React from 'react'; +import ReactDOM from 'react-dom'; +import { act } from 'react-dom/test-utils'; +import { getMockSheetInstance, getContainer } from 'tests/util/helpers'; +import { Export } from '@/components/export'; + +describe('header export component render tests', () => { + test('should render export and dropdown keep invisible', () => { + act(() => { + const sheet = getMockSheetInstance(); + + ReactDOM.render(, getContainer()); + }); + + // export 组件 + expect(document.querySelector('.antv-s2-export')).toBeDefined(); + + // dropdown 不应该渲染 + expect(document.querySelector('.ant-dropdown')).toBe(null); + }); + + test('should render export dropdown menu', () => { + act(() => { + const sheet = getMockSheetInstance(); + + ReactDOM.render( + , + getContainer(), + ); + }); + + // dropdown组件 + expect(document.querySelector('.ant-dropdown')).toBeDefined(); + }); +}); diff --git a/packages/s2-react/src/components/export/index.tsx b/packages/s2-react/src/components/export/index.tsx index 0e4ef8c2e9..25a790af80 100644 --- a/packages/s2-react/src/components/export/index.tsx +++ b/packages/s2-react/src/components/export/index.tsx @@ -6,7 +6,7 @@ import { SpreadSheet, i18n, } from '@antv/s2'; -import { Dropdown, Menu, message } from 'antd'; +import { Dropdown, Menu, message, type DropDownProps } from 'antd'; import cx from 'classnames'; import React from 'react'; import { DotIcon } from '../icons'; @@ -31,6 +31,8 @@ export interface ExportCfgProps { errorText?: string; fileName?: string; syncCopy?: boolean; + // ref: https://ant.design/components/dropdown-cn/#API + dropdown?: DropDownProps; } export interface ExportProps extends ExportCfgProps { @@ -50,6 +52,8 @@ export const Export: React.FC = React.memo((props) => { errorText = i18n('操作失败'), sheet, fileName, + open, + dropdown, ...restProps } = props; @@ -102,6 +106,7 @@ export const Export: React.FC = React.memo((props) => { trigger={['click']} className={cx(PRE_CLASS, className)} {...restProps} + {...dropdown} >