diff --git a/src/components/AsideHeader/AsideHeader.tsx b/src/components/AsideHeader/AsideHeader.tsx index 2203a74..47f24bd 100644 --- a/src/components/AsideHeader/AsideHeader.tsx +++ b/src/components/AsideHeader/AsideHeader.tsx @@ -7,7 +7,7 @@ import {ASIDE_HEADER_COMPACT_WIDTH, ASIDE_HEADER_EXPANDED_WIDTH} from '../consta import {Content} from '../Content'; import {AsideHeaderContextProvider, AsideHeaderInnerContextProvider} from './AsideHeaderContext'; -import {AsideHeaderGeneralProps, AsideHeaderDefaultProps, AsideHeaderInnerProps} from './types'; +import {AsideHeaderGeneralProps, AsideHeaderDefaultProps} from './types'; import {FirstPanel} from './components'; import {b} from './utils'; @@ -18,7 +18,7 @@ export interface AsideHeaderProps extends AsideHeaderGeneralProps, Partial {} -export const AsideHeader = (props: AsideHeaderInnerProps) => { +export const AsideHeader = React.forwardRef((props, ref) => { const {className, compact, onClosePanel} = props; const size = compact ? ASIDE_HEADER_COMPACT_WIDTH : ASIDE_HEADER_EXPANDED_WIDTH; @@ -43,7 +43,7 @@ export const AsideHeader = (props: AsideHeaderInnerProps) => {
{/* First Panel */} - + {/* Second Panel */} { ); -}; +}); diff --git a/src/components/AsideHeader/components/FirstPanel.tsx b/src/components/AsideHeader/components/FirstPanel.tsx index 50d2a07..d53d9b0 100644 --- a/src/components/AsideHeader/components/FirstPanel.tsx +++ b/src/components/AsideHeader/components/FirstPanel.tsx @@ -8,7 +8,7 @@ import {Header} from './Header'; import {CollapseButton} from './CollapseButton'; import {Panels} from './Panels'; -export const FirstPanel = () => { +export const FirstPanel = React.forwardRef((_props, ref) => { const { size, onItemClick, @@ -20,7 +20,7 @@ export const FirstPanel = () => { compact, } = useAsideHeaderInnerContext(); - const asideRef = useRef(null); + const asideRef = ref || useRef(null); return ( <> @@ -52,4 +52,4 @@ export const FirstPanel = () => { ); -}; +}); diff --git a/src/components/AsideHeader/types.tsx b/src/components/AsideHeader/types.tsx index dc48f3f..4e39bbc 100644 --- a/src/components/AsideHeader/types.tsx +++ b/src/components/AsideHeader/types.tsx @@ -14,7 +14,7 @@ export interface AsideHeaderGeneralProps { renderFooter?: (data: { size: number; compact: boolean; - asideRef: React.RefObject; + asideRef: React.ForwardedRef; }) => React.ReactNode; onClosePanel?: () => void; onChangeCompact?: (compact: boolean) => void;