mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-02 12:09:14 +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>) => {
|
||||
e?.preventDefault();
|
||||
e?.stopPropagation();
|
||||
|
||||
if (copyConfig.text === undefined) {
|
||||
copyConfig.text = String(children);
|
||||
|
@ -193,5 +193,18 @@ describe('Typography copy', () => {
|
||||
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