Skip to content

Commit

Permalink
fix: typography expanded should not break lines (#48340)
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Apr 8, 2024
1 parent 4a25c9f commit 61c8a43
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion BUG_VERSIONS.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@
"5.12.6": ["https://github.com/ant-design/ant-design/issues/46719"],
"5.13.0": ["https://github.com/ant-design/ant-design/pull/46962"],
"5.14.0": ["https://github.com/ant-design/ant-design/issues/47354"],
"5.15.0": ["https://github.com/ant-design/ant-design/pull/47504#issuecomment-1980459433"]
"5.15.0": ["https://github.com/ant-design/ant-design/pull/47504#issuecomment-1980459433"],
">= 5.16.0 <= 5.16.1": ["https://github.com/ant-design/ant-design/issues/48200"]
}
2 changes: 1 addition & 1 deletion components/typography/Base/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ const Base = React.forwardRef<HTMLElement, BlockProps>((props, ref) => {
[`${prefixCls}-${type}`]: type,
[`${prefixCls}-disabled`]: disabled,
[`${prefixCls}-ellipsis`]: enableEllipsis,
[`${prefixCls}-single-line`]: mergedEnableEllipsis && rows === 1,
[`${prefixCls}-single-line`]: mergedEnableEllipsis && rows === 1 && !expanded,
[`${prefixCls}-ellipsis-single-line`]: cssTextOverflow,
[`${prefixCls}-ellipsis-multiple-line`]: cssLineClamp,
},
Expand Down
14 changes: 14 additions & 0 deletions components/typography/__tests__/ellipsis.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -507,4 +507,18 @@ describe('Typography.Ellipsis', () => {
await waitFakeTimer();
expect(document.querySelector('.ant-tooltip')).toBeTruthy();
});

it('not force single line if expanded', () => {
const renderDemo = (expanded: boolean) => (
<Base ellipsis={{ rows: 1, expanded, expandable: 'collapsible' }} component="p">
{fullStr}
</Base>
);

const { container, rerender } = render(renderDemo(false));
expect(container.querySelector('.ant-typography-single-line')).toBeTruthy();

rerender(renderDemo(true));
expect(container.querySelector('.ant-typography-single-line')).toBeFalsy();
});
});

0 comments on commit 61c8a43

Please sign in to comment.