@@ -11,7 +11,7 @@ export interface COffcanvasProps extends HTMLAttributes<HTMLDivElement> {
1111 /**
1212 * Apply a backdrop on body while offcanvas is open.
1313 */
14- backdrop ?: boolean
14+ backdrop ?: boolean | 'static'
1515 /**
1616 * A string of all className you want applied to the base component.
1717 */
@@ -105,6 +105,12 @@ export const COffcanvas = forwardRef<HTMLDivElement, COffcanvasProps>(
105105 const handleDismiss = ( ) => {
106106 setVisible ( false )
107107 }
108+
109+ const handleBackdropDismiss = ( ) => {
110+ if ( backdrop !== 'static' ) {
111+ setVisible ( false )
112+ }
113+ }
108114
109115 const handleKeyDown = useCallback (
110116 ( event : React . KeyboardEvent < HTMLDivElement > ) => {
@@ -154,15 +160,15 @@ export const COffcanvas = forwardRef<HTMLDivElement, COffcanvasProps>(
154160 createPortal (
155161 < CBackdrop
156162 className = "offcanvas-backdrop"
157- onClick = { handleDismiss }
163+ onClick = { handleBackdropDismiss }
158164 visible = { _visible }
159165 /> ,
160166 document . body ,
161167 )
162168 : backdrop && (
163169 < CBackdrop
164170 className = "offcanvas-backdrop"
165- onClick = { handleDismiss }
171+ onClick = { handleBackdropDismiss }
166172 visible = { _visible }
167173 />
168174 ) }
@@ -172,7 +178,7 @@ export const COffcanvas = forwardRef<HTMLDivElement, COffcanvasProps>(
172178)
173179
174180COffcanvas . propTypes = {
175- backdrop : PropTypes . bool ,
181+ backdrop : PropTypes . oneOfType ( [ PropTypes . bool , PropTypes . oneOf < 'static' > ( [ 'static' ] ) ] ) ,
176182 children : PropTypes . node ,
177183 className : PropTypes . string ,
178184 keyboard : PropTypes . bool ,
0 commit comments