Skip to content

Commit 6c50714

Browse files
committed
chore: use motion ref
1 parent 25475b0 commit 6c50714

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/DrawerPopup.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { CSSMotionProps } from 'rc-motion';
55
import type { DrawerPanelRef } from './DrawerPanel';
66
import DrawerPanel from './DrawerPanel';
77
import type ScrollLocker from 'rc-util/lib/Dom/scrollLocker';
8+
import { composeRef } from 'rc-util/lib/ref';
89
import DrawerContext from './context';
910
import type { DrawerContextProps } from './context';
1011

@@ -180,7 +181,10 @@ export default function DrawerPopup(props: DrawerPopupProps) {
180181
// ============================ Mask ============================
181182
const maskNode: React.ReactNode = mask && (
182183
<CSSMotion key="mask" {...maskMotion} visible={open}>
183-
{({ className: motionMaskClassName, style: motionMaskStyle }) => {
184+
{(
185+
{ className: motionMaskClassName, style: motionMaskStyle },
186+
maskRef,
187+
) => {
184188
return (
185189
<div
186190
className={classNames(
@@ -194,6 +198,7 @@ export default function DrawerPopup(props: DrawerPopupProps) {
194198
...zIndexStyle,
195199
}}
196200
onClick={maskClosable && onClose}
201+
ref={maskRef}
197202
/>
198203
);
199204
}}
@@ -245,10 +250,10 @@ export default function DrawerPopup(props: DrawerPopupProps) {
245250
removeOnLeave={false}
246251
leavedClassName={`${prefixCls}-content-hidden`}
247252
>
248-
{({ className: motionClassName, style: motionStyle }) => {
253+
{({ className: motionClassName, style: motionStyle }, motionRef) => {
249254
return (
250255
<DrawerPanel
251-
ref={panelRef}
256+
ref={composeRef(motionRef, panelRef)}
252257
prefixCls={prefixCls}
253258
className={classNames(className, motionClassName)}
254259
style={{

0 commit comments

Comments
 (0)