diff --git a/.gitignore b/.gitignore index 76d4008..ffa877d 100755 --- a/.gitignore +++ b/.gitignore @@ -38,4 +38,5 @@ storybook # dumi .dumi/tmp -.dumi/tmp-production \ No newline at end of file +.dumi/tmp-production +pnpm-lock.yaml \ No newline at end of file diff --git a/src/DrawerPopup.tsx b/src/DrawerPopup.tsx index 2a934ef..762de67 100644 --- a/src/DrawerPopup.tsx +++ b/src/DrawerPopup.tsx @@ -74,6 +74,7 @@ export interface DrawerPopupProps // styles styles?: DrawerStyles; + drawerRender?: (node: React.ReactNode) => React.ReactNode; } function DrawerPopup(props: DrawerPopupProps, ref: React.Ref) { @@ -121,6 +122,7 @@ function DrawerPopup(props: DrawerPopupProps, ref: React.Ref) { onKeyUp, styles, + drawerRender, } = props; // ================================ Refs ================================ @@ -291,6 +293,22 @@ function DrawerPopup(props: DrawerPopupProps, ref: React.Ref) { leavedClassName={`${prefixCls}-content-wrapper-hidden`} > {({ className: motionClassName, style: motionStyle }, motionRef) => { + const content = ( + + {children} + + ); return (
) { }} {...pickAttrs(props, { data: true })} > - - {children} - + {drawerRender ? drawerRender(content) : content}
); }} diff --git a/tests/index.spec.tsx b/tests/index.spec.tsx index 98f193a..fcd2b11 100755 --- a/tests/index.spec.tsx +++ b/tests/index.spec.tsx @@ -467,4 +467,11 @@ describe('rc-drawer-menu', () => { ); unmount(); }); + it('should support drawerRender', () => { + const { unmount } = render( +
{dom}
} open />, + ); + expect(document.querySelector('#test')).toBeTruthy(); + unmount(); + }); });