44 MutableRefObject ,
55 SetStateAction ,
66 useEffect ,
7+ useLayoutEffect ,
78 useRef ,
89 useState ,
910} from 'react'
@@ -16,6 +17,7 @@ import {
1617} from '../../../../lib'
1718import {
1819 CertificatePageLayout ,
20+ hideSiblings ,
1921 HiringManagerView ,
2022 PageTitle ,
2123 TCACertification ,
@@ -34,6 +36,7 @@ interface UserCertificationViewBaseProps {
3436
3537const UserCertificationViewBase : FC < UserCertificationViewBaseProps > = ( props : UserCertificationViewBaseProps ) => {
3638 const [ queryParams ] : [ URLSearchParams , any ] = useSearchParams ( )
39+ const wrapElRef : MutableRefObject < HTMLElement | any > = useRef ( )
3740
3841 const tcaCertificationPath : string = getTCACertificationPath ( `${ props . certification ?. dashedName } ` )
3942 const certificateElRef : MutableRefObject < HTMLDivElement | any > = useRef ( )
@@ -55,6 +58,15 @@ const UserCertificationViewBase: FC<UserCertificationViewBaseProps> = (props: Us
5558 . then ( verified => setIsMemberVerified ( verified ) )
5659 } , [ props . enrollment ] )
5760
61+ useLayoutEffect ( ( ) => {
62+ const el : HTMLElement = wrapElRef . current
63+ if ( ! el || ! isModalView ) {
64+ return
65+ }
66+
67+ hideSiblings ( el . parentElement as HTMLElement )
68+ } , [ isModalView ] )
69+
5870 return (
5971 < >
6072 < PageTitle >
@@ -74,8 +86,8 @@ const UserCertificationViewBase: FC<UserCertificationViewBaseProps> = (props: Us
7486 </ CertificatePageLayout >
7587 ) }
7688
77- { props . profile && props . certification && props . enrollment && (
78- < div className = 'full-height-frame' >
89+ < div className = 'full-height-frame' ref = { wrapElRef } >
90+ { props . profile && props . certification && props . enrollment && (
7991 < HiringManagerView
8092 certification = { props . certification }
8193 completedAt = { ( props . enrollment . completedAt ?? undefined ) as string }
@@ -88,8 +100,8 @@ const UserCertificationViewBase: FC<UserCertificationViewBaseProps> = (props: Us
88100 isPreview = { props . isPreview }
89101 isModalView = { isModalView }
90102 />
91- </ div >
92- ) }
103+ ) }
104+ </ div >
93105 </ >
94106 )
95107}
0 commit comments