Browse Source

fix: Pass custom prefixCls to Typography from Base (#38580) (#38586)

* fix: Pass custom prefixCls to Typography from Base (#38580)

* test: Added test for typography custom prefixCls
pull/38605/head
Matthew 2 years ago
committed by GitHub
parent
commit
52dedca8ed
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      components/typography/Base/index.tsx
  2. 20
      components/typography/__tests__/prefixCls.test.tsx

3
components/typography/Base/index.tsx

@ -277,7 +277,7 @@ const Base = React.forwardRef<HTMLElement, BlockProps>((props, ref) => {
const cssLineClamp = mergedEnableEllipsis && rows > 1 && cssEllipsis;
// >>>>> Expand
const onExpandClick: React.MouseEventHandler<HTMLElement> = e => {
const onExpandClick: React.MouseEventHandler<HTMLElement> = (e) => {
setExpanded(true);
ellipsisConfig.onExpand?.(e);
};
@ -510,6 +510,7 @@ const Base = React.forwardRef<HTMLElement, BlockProps>((props, ref) => {
},
className,
)}
prefixCls={customizePrefixCls}
style={{
...style,
WebkitLineClamp: cssLineClamp ? rows : undefined,

20
components/typography/__tests__/prefixCls.test.tsx

@ -0,0 +1,20 @@
import React from 'react';
import { render } from '../../../tests/utils';
import Base from '../Base';
describe('Typography keep prefixCls', () => {
describe('Base', () => {
it('should support className when has prefix', () => {
const { container: wrapper } = render(
<Base component="p" prefixCls="custom-prefixCls" className="custom-class">
test prefixCls
</Base>,
);
expect(
(wrapper.firstChild as HTMLElement)?.className.includes('custom-prefixCls'),
).toBeTruthy();
expect((wrapper.firstChild as HTMLElement)?.className.includes('custom-class')).toBeTruthy();
});
});
});
Loading…
Cancel
Save