Skip to content

Commit a3fc7ee

Browse files
committed
chore: move ref to penal props
1 parent adc7535 commit a3fc7ee

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/DrawerPanel.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as React from 'react';
22
import classNames from 'classnames';
33
import type { Placement } from './Drawer';
44
import KeyCode from 'rc-util/lib/KeyCode';
5+
import { composeRef } from 'rc-util/lib/ref';
56

67
export interface DrawerPanelRef {
78
focus: VoidFunction;
@@ -16,6 +17,7 @@ export interface DrawerPanelProps {
1617
placement: Placement;
1718
children?: React.ReactNode;
1819
onClose?: React.KeyboardEventHandler<HTMLElement>;
20+
containerRef?: React.Ref<HTMLDivElement>;
1921
}
2022

2123
const sentinelStyle: React.CSSProperties = {
@@ -37,6 +39,7 @@ const DrawerPanel = React.forwardRef<DrawerPanelRef, DrawerPanelProps>(
3739
height,
3840
children,
3941
onClose,
42+
containerRef,
4043
} = props;
4144

4245
// ================================ Refs ================================
@@ -104,7 +107,7 @@ const DrawerPanel = React.forwardRef<DrawerPanelRef, DrawerPanelProps>(
104107
aria-modal="true"
105108
role="dialog"
106109
tabIndex={-1}
107-
ref={panelRef}
110+
ref={composeRef(panelRef, containerRef)}
108111
onKeyDown={onPanelKeyDown}
109112
>
110113
<div

src/DrawerPopup.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ 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';
98
import DrawerContext from './context';
109
import type { DrawerContextProps } from './context';
1110

@@ -253,7 +252,8 @@ export default function DrawerPopup(props: DrawerPopupProps) {
253252
{({ className: motionClassName, style: motionStyle }, motionRef) => {
254253
return (
255254
<DrawerPanel
256-
ref={composeRef(motionRef, panelRef)}
255+
ref={panelRef}
256+
containerRef={motionRef}
257257
prefixCls={prefixCls}
258258
className={classNames(className, motionClassName)}
259259
style={{

0 commit comments

Comments
 (0)