Skip to content

Commit 6c52162

Browse files
authored
fix(modal): title props support render function (#3030)
1 parent 4a3e310 commit 6c52162

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

components/modal/ConfirmDialog.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ export default {
9494
<div class={`${contentPrefixCls}-body`}>
9595
{iconNode}
9696
{props.title === undefined ? null : (
97-
<span class={`${contentPrefixCls}-title`}>{props.title}</span>
97+
<span class={`${contentPrefixCls}-title`}>
98+
{typeof props.title === 'function' ? props.title(h) : props.title}
99+
</span>
98100
)}
99101
<div class={`${contentPrefixCls}-content`}>
100102
{typeof props.content === 'function' ? props.content(h) : props.content}

components/modal/__tests__/confirm.test.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ describe('Modal.confirm triggers callbacks correctly', () => {
8888
expect($$('.ant-btn')[1].disabled).toBe(true);
8989
});
9090

91-
fit('trigger onCancel once when click on cancel button', async () => {
91+
it('trigger onCancel once when click on cancel button', async () => {
9292
const arr = ['info', 'success', 'warning', 'error'];
9393
for (let type of arr) {
9494
Modal[type]({
@@ -102,4 +102,12 @@ describe('Modal.confirm triggers callbacks correctly', () => {
102102
expect($$(`.ant-modal-confirm-${type}`)).toHaveLength(0);
103103
}
104104
});
105+
106+
it('should render title', async () => {
107+
open({
108+
title: h => <span>title</span>,
109+
});
110+
await sleep();
111+
expect($$('.ant-modal-confirm-title')[0].innerHTML).toBe('<span>title</span>');
112+
});
105113
});

0 commit comments

Comments
 (0)