fix: Popconfirm text missing (#46812)

This commit is contained in:
二货爱吃白萝卜 2024-01-05 15:29:18 +08:00 committed by GitHub
parent 15324982ab
commit 8f6f8de9b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -73,7 +73,7 @@ export const Overlay: React.FC<OverlayProps> = (props) => {
<div className={`${prefixCls}-buttons`}>
{showCancel && (
<Button onClick={onCancel} size="small" {...cancelButtonProps}>
{cancelText ?? contextLocale?.cancelText}
{cancelText || contextLocale?.cancelText}
</Button>
)}
<ActionButton
@ -88,7 +88,7 @@ export const Overlay: React.FC<OverlayProps> = (props) => {
quitOnNullishReturnValue
emitEvent
>
{okText ?? contextLocale?.okText}
{okText || contextLocale?.okText}
</ActionButton>
</div>
</div>

View File

@ -1,5 +1,6 @@
import { spyElementPrototype } from 'rc-util/lib/test/domHook';
import React from 'react';
import { spyElementPrototype } from 'rc-util/lib/test/domHook';
import Popconfirm from '..';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
@ -354,4 +355,15 @@ describe('Popconfirm', () => {
expect(onOpenChange).toHaveBeenCalledTimes(1);
expect(onVisibleChange).toHaveBeenCalledTimes(1);
});
it('okText & cancelText could be empty', () => {
render(
<Popconfirm title="" okText="" cancelText="" open>
<span />
</Popconfirm>,
);
expect(document.body.querySelectorAll('.ant-btn')[0].textContent).toBe('Cancel');
expect(document.body.querySelectorAll('.ant-btn')[1].textContent).toBe('OK');
});
});