Browse Source

fix(modal): title props support render function (#3030)

pull/3052/head
John60676 4 years ago committed by GitHub
parent
commit
6c521620b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      components/modal/ConfirmDialog.jsx
  2. 10
      components/modal/__tests__/confirm.test.js

4
components/modal/ConfirmDialog.jsx

@ -94,7 +94,9 @@ export default {
<div class={`${contentPrefixCls}-body`}>
{iconNode}
{props.title === undefined ? null : (
<span class={`${contentPrefixCls}-title`}>{props.title}</span>
<span class={`${contentPrefixCls}-title`}>
{typeof props.title === 'function' ? props.title(h) : props.title}
</span>
)}
<div class={`${contentPrefixCls}-content`}>
{typeof props.content === 'function' ? props.content(h) : props.content}

10
components/modal/__tests__/confirm.test.js

@ -88,7 +88,7 @@ describe('Modal.confirm triggers callbacks correctly', () => {
expect($$('.ant-btn')[1].disabled).toBe(true);
});
fit('trigger onCancel once when click on cancel button', async () => {
it('trigger onCancel once when click on cancel button', async () => {
const arr = ['info', 'success', 'warning', 'error'];
for (let type of arr) {
Modal[type]({
@ -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 => <span>title</span>,
});
await sleep();
expect($$('.ant-modal-confirm-title')[0].innerHTML).toBe('<span>title</span>');
});
});

Loading…
Cancel
Save