Skip to content

Commit 9ac18c5

Browse files
authored
fix(modal): title props support render function (#3031)
1 parent 157d0e7 commit 9ac18c5

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

components/modal/ConfirmDialog.jsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ const ConfirmDialog = (_, { attrs }) => {
8282
<div class={`${contentPrefixCls}-body`}>
8383
{typeof icon === 'function' ? icon() : icon}
8484
{attrs.title === undefined ? null : (
85-
<span class={`${contentPrefixCls}-title`}>{attrs.title}</span>
85+
<span class={`${contentPrefixCls}-title`}>
86+
{typeof attrs.title === 'function' ? attrs.title() : attrs.title}
87+
</span>
8688
)}
8789
<div class={`${contentPrefixCls}-content`}>
8890
{typeof attrs.content === 'function' ? attrs.content() : attrs.content}

components/modal/__tests__/confirm.test.js

+8
Original file line numberDiff line numberDiff line change
@@ -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)