@@ -21,9 +21,13 @@ export interface COffcanvasProps extends HTMLAttributes<HTMLDivElement> {
21
21
*/
22
22
keyboard ?: boolean
23
23
/**
24
- * Callback fired when the component requests to be closed .
24
+ * Callback fired when the component requests to be hidden .
25
25
*/
26
- onClose ?: ( ) => void
26
+ onHide ?: ( ) => void
27
+ /**
28
+ * Callback fired when the component requests to be shown.
29
+ */
30
+ onShow ?: ( ) => void
27
31
/**
28
32
* Components placement, there’s no default placement.
29
33
*/
@@ -49,7 +53,8 @@ export const COffcanvas = forwardRef<HTMLDivElement, COffcanvasProps>(
49
53
backdrop = true ,
50
54
className,
51
55
keyboard = true ,
52
- onClose,
56
+ onHide,
57
+ onShow,
53
58
placement,
54
59
portal = true ,
55
60
scroll = false ,
@@ -99,7 +104,6 @@ export const COffcanvas = forwardRef<HTMLDivElement, COffcanvasProps>(
99
104
100
105
const handleDismiss = ( ) => {
101
106
setVisible ( false )
102
- return onClose && onClose ( )
103
107
}
104
108
105
109
const handleKeyDown = useCallback (
@@ -131,7 +135,13 @@ export const COffcanvas = forwardRef<HTMLDivElement, COffcanvasProps>(
131
135
132
136
return (
133
137
< >
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
+ >
135
145
{ ( state ) => {
136
146
return typeof window !== 'undefined' && portal
137
147
? createPortal ( offcanvas ( forkedRef , state ) , document . body )
@@ -152,7 +162,8 @@ COffcanvas.propTypes = {
152
162
children : PropTypes . node ,
153
163
className : PropTypes . string ,
154
164
keyboard : PropTypes . bool ,
155
- onClose : PropTypes . func ,
165
+ onHide : PropTypes . func ,
166
+ onShow : PropTypes . func ,
156
167
placement : PropTypes . oneOf < 'start' | 'end' | 'top' | 'bottom' > ( [ 'start' , 'end' , 'top' , 'bottom' ] )
157
168
. isRequired ,
158
169
portal : PropTypes . bool ,
0 commit comments