Skip to content

Commit

Permalink
fix: Typography dynamic of copyable & eidtable (#48350)
Browse files Browse the repository at this point in the history
* fix: editable should show

* test: test driven

* fix: copyable of render
  • Loading branch information
zombieJ committed Apr 9, 2024
1 parent 727aa2d commit 44cd534
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion components/typography/Base/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ const Base = React.forwardRef<HTMLElement, BlockProps>((props, ref) => {
width={ellipsisWidth}
onEllipsis={onJsEllipsis}
expanded={expanded}
miscDeps={[copied, expanded, copyLoading]}
miscDeps={[copied, expanded, copyLoading, enableEdit, enableCopy]}
>
{(node, canEllipsis) => {
let renderNode: React.ReactNode = node;
Expand Down
12 changes: 12 additions & 0 deletions components/typography/__tests__/copy.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -316,4 +316,16 @@ describe('Typography copy', () => {

spy.mockRestore();
});

it('dynamic set editable', () => {
const { container, rerender } = render(<Base component="p">test</Base>);
expect(container.querySelector('.ant-typography-copy')).toBeFalsy();

rerender(
<Base component="p" copyable>
test
</Base>,
);
expect(container.querySelector('.ant-typography-copy')).toBeTruthy();
});
});
12 changes: 12 additions & 0 deletions components/typography/__tests__/editable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,16 @@ describe('Typography.Editable', () => {

unmount();
});

it('dynamic set editable', () => {
const { container, rerender } = render(<Base component="p">test</Base>);
expect(container.querySelector('.ant-typography-edit')).toBeFalsy();

rerender(
<Base component="p" editable>
test
</Base>,
);
expect(container.querySelector('.ant-typography-edit')).toBeTruthy();
});
});

0 comments on commit 44cd534

Please sign in to comment.