diff --git a/components/typography/Base/index.tsx b/components/typography/Base/index.tsx index 70d8c99575..706fad6c8d 100644 --- a/components/typography/Base/index.tsx +++ b/components/typography/Base/index.tsx @@ -194,6 +194,7 @@ const Base = React.forwardRef((props: InternalBlockProps, ref: any) => { const onCopyClick = (e?: React.MouseEvent) => { e?.preventDefault(); + e?.stopPropagation(); if (copyConfig.text === undefined) { copyConfig.text = String(children); diff --git a/components/typography/__tests__/copy.test.tsx b/components/typography/__tests__/copy.test.tsx index 7dc502cd1e..d831d5c7de 100644 --- a/components/typography/__tests__/copy.test.tsx +++ b/components/typography/__tests__/copy.test.tsx @@ -193,5 +193,18 @@ describe('Typography copy', () => { tooltipLength: 0, }); }); + + it('copy click event stopPropagation', () => { + const onDivClick = jest.fn(); + const wrapper = mount( +
+ + test copy + +
, + ); + wrapper.find('.ant-typography-copy').first().simulate('click'); + expect(onDivClick).not.toBeCalled(); + }); }); });