((props, ref) => {
) : null;
+ const extraNode = extra ? (
+
+ {extra}
+
+ ) : null;
+
const headerNode = title ? (
((props, ref) => {
>
{title}
+ {extraNode}
- ) : null;
+ ) : (
+
+ {extraNode}
+
+ );
const closableObj = useMemo(() => {
if (typeof closable === 'object' && closable !== null) {
diff --git a/src/Dialog/Content/index.tsx b/src/Dialog/Content/index.tsx
index df6a97ea..b469f610 100644
--- a/src/Dialog/Content/index.tsx
+++ b/src/Dialog/Content/index.tsx
@@ -30,12 +30,17 @@ const Content = React.forwardRef((props, ref) => {
ariaId,
onVisibleChanged,
mousePosition,
+ extra,
} = props;
const dialogRef = useRef<{ nativeElement: HTMLElement } & CSSMotionStateRef>(null);
const panelRef = useRef(null);
+ const hasExtra = !!extra && !(typeof extra === 'string' && extra.trim() === '');
+
+ const curExtra = hasExtra ? extra : null;
+
// ============================== Refs ==============================
React.useImperativeHandle(ref, () => ({
...panelRef.current,
@@ -77,6 +82,7 @@ const Content = React.forwardRef((props, ref) => {
>;
@@ -55,4 +63,6 @@ export type IDialogPropTypes = {
// Refs
panelRef?: React.Ref;
+
+ extra?: ReactNode;
};
diff --git a/tests/__snapshots__/index.spec.tsx.snap b/tests/__snapshots__/index.spec.tsx.snap
index d7886512..6b2cb58e 100644
--- a/tests/__snapshots__/index.spec.tsx.snap
+++ b/tests/__snapshots__/index.spec.tsx.snap
@@ -35,6 +35,9 @@ exports[`dialog add rootClassName and rootStyle should render correct 1`] = `
class="rc-dialog-close-x"
/>
+
diff --git a/tests/index.spec.tsx b/tests/index.spec.tsx
index e6c075ea..954b5727 100644
--- a/tests/index.spec.tsx
+++ b/tests/index.spec.tsx
@@ -1,5 +1,5 @@
/* eslint-disable react/no-render-return-value, max-classes-per-file, func-names, no-console */
-import { fireEvent, render, act } from '@testing-library/react';
+import { fireEvent, render, act, screen } from '@testing-library/react';
import { Provider } from '@rc-component/motion';
import KeyCode from '@rc-component/util/lib/KeyCode';
import React, { cloneElement, useEffect } from 'react';
@@ -733,4 +733,40 @@ describe('dialog', () => {
expect(document.querySelector('.rc-dialog')).toBeTruthy();
expect(document.querySelector('.rc-dialog-close')).toBeFalsy();
});
+
+ it('should render extra when extra is a React node', () => {
+ render(