File tree Expand file tree Collapse file tree 1 file changed +19
-8
lines changed
packages/coreui-vue/src/components/focus-trap Expand file tree Collapse file tree 1 file changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -278,14 +278,25 @@ const CFocusTrap = defineComponent({
278278 containerRef,
279279 } )
280280
281- return ( ) =>
282- slots . default ?.( ) . map ( ( slot ) =>
283- cloneVNode ( slot , {
284- ref : ( el ) => {
285- containerRef . value = el as HTMLElement | null
286- } ,
287- } )
288- )
281+ return ( ) => {
282+ const vnodes = slots . default ?.( )
283+ const vnode = vnodes ?. [ 0 ]
284+ if ( ! vnode ) return null
285+
286+ const originalRef = ( vnode . props as any ) ?. ref
287+
288+ return cloneVNode ( vnode , {
289+ ref : ( el ) => {
290+ containerRef . value = el as HTMLElement | null
291+
292+ if ( typeof originalRef === 'function' ) {
293+ originalRef ( el )
294+ } else if ( originalRef && typeof originalRef === 'object' && 'value' in originalRef ) {
295+ ; ( originalRef as { value : any } ) . value = el
296+ }
297+ } ,
298+ } )
299+ }
289300 } ,
290301} )
291302
You can’t perform that action at this time.
0 commit comments