@@ -11,7 +11,7 @@ export interface COffcanvasProps extends HTMLAttributes<HTMLDivElement> {
11
11
/**
12
12
* Apply a backdrop on body while offcanvas is open.
13
13
*/
14
- backdrop ?: boolean
14
+ backdrop ?: boolean | string
15
15
/**
16
16
* A string of all className you want applied to the base component.
17
17
*/
@@ -105,6 +105,11 @@ export const COffcanvas = forwardRef<HTMLDivElement, COffcanvasProps>(
105
105
const handleDismiss = ( ) => {
106
106
setVisible ( false )
107
107
}
108
+ const handleBackdropDismiss = ( ) => {
109
+ if ( backdrop !== 'static' ) {
110
+ setVisible ( false )
111
+ }
112
+ }
108
113
109
114
const handleKeyDown = useCallback (
110
115
( event : React . KeyboardEvent < HTMLDivElement > ) => {
@@ -154,15 +159,15 @@ export const COffcanvas = forwardRef<HTMLDivElement, COffcanvasProps>(
154
159
createPortal (
155
160
< CBackdrop
156
161
className = "offcanvas-backdrop"
157
- onClick = { handleDismiss }
162
+ onClick = { handleBackdropDismiss }
158
163
visible = { _visible }
159
164
/> ,
160
165
document . body ,
161
166
)
162
167
: backdrop && (
163
168
< CBackdrop
164
169
className = "offcanvas-backdrop"
165
- onClick = { handleDismiss }
170
+ onClick = { handleBackdropDismiss }
166
171
visible = { _visible }
167
172
/>
168
173
) }
@@ -172,7 +177,7 @@ export const COffcanvas = forwardRef<HTMLDivElement, COffcanvasProps>(
172
177
)
173
178
174
179
COffcanvas . propTypes = {
175
- backdrop : PropTypes . bool ,
180
+ backdrop : PropTypes . oneOfType ( [ PropTypes . bool , PropTypes . string ] ) ,
176
181
children : PropTypes . node ,
177
182
className : PropTypes . string ,
178
183
keyboard : PropTypes . bool ,
0 commit comments