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