mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-06 07:56:28 +08:00
fix: Typography copyable add stopPropagation (#33998)
* fix: Typography copyable add stopPropagation * add test
This commit is contained in:
parent
4f8646f957
commit
19cc7d49e2
@ -194,6 +194,7 @@ const Base = React.forwardRef((props: InternalBlockProps, ref: any) => {
|
|||||||
|
|
||||||
const onCopyClick = (e?: React.MouseEvent<HTMLDivElement>) => {
|
const onCopyClick = (e?: React.MouseEvent<HTMLDivElement>) => {
|
||||||
e?.preventDefault();
|
e?.preventDefault();
|
||||||
|
e?.stopPropagation();
|
||||||
|
|
||||||
if (copyConfig.text === undefined) {
|
if (copyConfig.text === undefined) {
|
||||||
copyConfig.text = String(children);
|
copyConfig.text = String(children);
|
||||||
|
@ -193,5 +193,18 @@ describe('Typography copy', () => {
|
|||||||
tooltipLength: 0,
|
tooltipLength: 0,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('copy click event stopPropagation', () => {
|
||||||
|
const onDivClick = jest.fn();
|
||||||
|
const wrapper = mount(
|
||||||
|
<div onClick={onDivClick}>
|
||||||
|
<Base component="p" copyable>
|
||||||
|
test copy
|
||||||
|
</Base>
|
||||||
|
</div>,
|
||||||
|
);
|
||||||
|
wrapper.find('.ant-typography-copy').first().simulate('click');
|
||||||
|
expect(onDivClick).not.toBeCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user