@@ -21,9 +21,13 @@ export interface COffcanvasProps extends HTMLAttributes<HTMLDivElement> {
2121 */
2222 keyboard ?: boolean
2323 /**
24- * Callback fired when the component requests to be closed .
24+ * Callback fired when the component requests to be hidden .
2525 */
26- onClose ?: ( ) => void
26+ onHide ?: ( ) => void
27+ /**
28+ * Callback fired when the component requests to be shown.
29+ */
30+ onShow ?: ( ) => void
2731 /**
2832 * Components placement, there’s no default placement.
2933 */
@@ -49,7 +53,8 @@ export const COffcanvas = forwardRef<HTMLDivElement, COffcanvasProps>(
4953 backdrop = true ,
5054 className,
5155 keyboard = true ,
52- onClose,
56+ onHide,
57+ onShow,
5358 placement,
5459 portal = true ,
5560 scroll = false ,
@@ -99,7 +104,6 @@ export const COffcanvas = forwardRef<HTMLDivElement, COffcanvasProps>(
99104
100105 const handleDismiss = ( ) => {
101106 setVisible ( false )
102- return onClose && onClose ( )
103107 }
104108
105109 const handleKeyDown = useCallback (
@@ -131,7 +135,13 @@ export const COffcanvas = forwardRef<HTMLDivElement, COffcanvasProps>(
131135
132136 return (
133137 < >
134- < Transition in = { _visible } timeout = { 300 } onEntered = { ( ) => offcanvasRef . current ?. focus ( ) } >
138+ < Transition
139+ in = { _visible }
140+ timeout = { 300 }
141+ onEnter = { onShow }
142+ onEntered = { ( ) => offcanvasRef . current ?. focus ( ) }
143+ onExit = { onHide }
144+ >
135145 { ( state ) => {
136146 return typeof window !== 'undefined' && portal
137147 ? createPortal ( offcanvas ( forkedRef , state ) , document . body )
@@ -152,7 +162,8 @@ COffcanvas.propTypes = {
152162 children : PropTypes . node ,
153163 className : PropTypes . string ,
154164 keyboard : PropTypes . bool ,
155- onClose : PropTypes . func ,
165+ onHide : PropTypes . func ,
166+ onShow : PropTypes . func ,
156167 placement : PropTypes . oneOf < 'start' | 'end' | 'top' | 'bottom' > ( [ 'start' , 'end' , 'top' , 'bottom' ] )
157168 . isRequired ,
158169 portal : PropTypes . bool ,
0 commit comments