From 1df30b0af18dc1a70a7d2c1b743bf781683f9109 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 23 Oct 2020 11:38:34 +0800 Subject: [PATCH] fix(modal): title props support render function --- components/modal/ConfirmDialog.jsx | 4 +++- components/modal/__tests__/confirm.test.js | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/components/modal/ConfirmDialog.jsx b/components/modal/ConfirmDialog.jsx index b51efb2b46..6ab9124a3c 100644 --- a/components/modal/ConfirmDialog.jsx +++ b/components/modal/ConfirmDialog.jsx @@ -82,7 +82,9 @@ const ConfirmDialog = (_, { attrs }) => {
{typeof icon === 'function' ? icon() : icon} {attrs.title === undefined ? null : ( - {attrs.title} + + {typeof attrs.title === 'function' ? attrs.title() : attrs.title} + )}
{typeof attrs.content === 'function' ? attrs.content() : attrs.content} diff --git a/components/modal/__tests__/confirm.test.js b/components/modal/__tests__/confirm.test.js index 224fe5f1ef..d5d46ce2a2 100644 --- a/components/modal/__tests__/confirm.test.js +++ b/components/modal/__tests__/confirm.test.js @@ -102,4 +102,12 @@ describe('Modal.confirm triggers callbacks correctly', () => { expect($$(`.ant-modal-confirm-${type}`)).toHaveLength(0); } }); + + it('should render title', async () => { + open({ + title: h => title, + }); + await sleep(); + expect($$('.ant-modal-confirm-title')[0].innerHTML).toBe('title'); + }); });