From 71533ff2a3ea26e054cb0dca7025b0443516cc91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E7=88=B1=E5=90=83=E7=99=BD=E8=90=9D?= =?UTF-8?q?=E5=8D=9C?= Date: Tue, 3 Sep 2024 16:20:44 +0800 Subject: [PATCH] fix: Typography dead loop (#50688) --- BUG_VERSIONS.json | 3 ++- components/typography/__tests__/ellipsis.test.tsx | 11 +++++++++++ components/typography/hooks/useTooltipProps.ts | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/BUG_VERSIONS.json b/BUG_VERSIONS.json index 7542cbdc35..ca2a7aa428 100644 --- a/BUG_VERSIONS.json +++ b/BUG_VERSIONS.json @@ -56,5 +56,6 @@ ">= 5.16.0 <= 5.16.1": ["https://github.com/ant-design/ant-design/issues/48200"], "5.16.3": ["https://github.com/ant-design/ant-design/issues/48568"], "5.17.1": ["https://github.com/ant-design/ant-design/issues/48913"], - "5.18.2": ["https://github.com/ant-design/ant-design/pull/49487"] + "5.18.2": ["https://github.com/ant-design/ant-design/pull/49487"], + "5.20.4": ["https://github.com/ant-design/ant-design/issues/50687"] } diff --git a/components/typography/__tests__/ellipsis.test.tsx b/components/typography/__tests__/ellipsis.test.tsx index 5340e6f60e..6e92e29a20 100644 --- a/components/typography/__tests__/ellipsis.test.tsx +++ b/components/typography/__tests__/ellipsis.test.tsx @@ -633,4 +633,15 @@ describe('Typography.Ellipsis', () => { rerender(renderDemo(true)); expect(container.querySelector('.ant-typography-collapse')).toBeTruthy(); }); + + it('no dead loop', () => { + const tooltipObj: any = {}; + tooltipObj.loop = tooltipObj; + + render( + + {fullStr} + , + ); + }); }); diff --git a/components/typography/hooks/useTooltipProps.ts b/components/typography/hooks/useTooltipProps.ts index 8b83569e90..fe540585ba 100644 --- a/components/typography/hooks/useTooltipProps.ts +++ b/components/typography/hooks/useTooltipProps.ts @@ -17,6 +17,6 @@ const useTooltipProps = ( return { title: editConfigText ?? children, ...tooltip }; } return { title: tooltip }; - }, [typeof tooltip === 'object' ? JSON.stringify(tooltip) : tooltip, editConfigText, children]); + }, [tooltip, editConfigText, children]); export default useTooltipProps;