Skip to content

Commit 8f95447

Browse files
author
WB01676250
committed
fix: typography
1 parent 726e717 commit 8f95447

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

components/typography/Base/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,9 @@ const Base = React.forwardRef<HTMLElement, BlockProps>((props, ref) => {
426426
renderOperations(canEllipsis),
427427
];
428428

429+
// https://github.com/ant-design/ant-design/issues/54265
430+
const mergedComponent = component === 'a' && disabled ? 'span' : component;
431+
429432
return (
430433
<ResizeObserver onResize={onResize} disabled={!mergedEnableEllipsis}>
431434
{(resizeRef: React.RefObject<HTMLElement>) => (
@@ -450,7 +453,7 @@ const Base = React.forwardRef<HTMLElement, BlockProps>((props, ref) => {
450453
...style,
451454
WebkitLineClamp: cssLineClamp ? rows : undefined,
452455
}}
453-
component={component}
456+
component={mergedComponent}
454457
ref={composeRef(resizeRef, typographyRef, ref)}
455458
direction={direction}
456459
onClick={triggerType.includes('text') ? onEditClick : undefined}

components/typography/__tests__/copy.test.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,4 +371,21 @@ describe('Typography copy', () => {
371371

372372
spy.mockRestore();
373373
});
374+
375+
it('typography link copy and disabled coexist, copy should working', () => {
376+
const spy = jest.spyOn(copyObj, 'default');
377+
378+
const bamboo = 'bamboo';
379+
380+
const { container } = render(
381+
<Base component="a" copyable disabled>
382+
{bamboo}
383+
</Base>,
384+
);
385+
fireEvent.click(container.querySelector('.ant-typography-copy')!);
386+
387+
expect(spy).toHaveBeenCalled();
388+
389+
spy.mockRestore();
390+
});
374391
});

0 commit comments

Comments
 (0)