44 useMemo ,
55 useRef ,
66} from 'react' ;
7+ import classNames from 'classnames' ;
78import { useDispatch } from 'react-redux' ;
89import { useToggle } from '@openedx/paragon' ;
910import { isEmpty } from 'lodash' ;
@@ -24,6 +25,7 @@ import { UpstreamInfoIcon } from '@src/generic/upstream-info-icon';
2425import { PreviewLibraryXBlockChanges } from '@src/course-unit/preview-changes' ;
2526import { invalidateLinksQuery } from '@src/course-libraries/data/apiHooks' ;
2627import type { XBlock } from '@src/data/types' ;
28+ import { useSidebarContext } from '../common/context/SidebarContext' ;
2729
2830interface UnitCardProps {
2931 unit : XBlock ;
@@ -70,6 +72,7 @@ const UnitCard = ({
7072 const currentRef = useRef ( null ) ;
7173 const dispatch = useDispatch ( ) ;
7274 const [ searchParams ] = useSearchParams ( ) ;
75+ const { selectedContainerId, openContainerInfoSidebar } = useSidebarContext ( ) ;
7376 const locatorId = searchParams . get ( 'show' ) ;
7477 const isScrolledToElement = locatorId === unit . id ;
7578 const [ isFormOpen , openForm , closeForm ] = useToggle ( false ) ;
@@ -207,6 +210,12 @@ const UnitCard = ({
207210 && ! subsection . upstreamInfo ?. upstreamRef
208211 ) ;
209212
213+ const onClickCard = useCallback ( ( e : React . MouseEvent ) => {
214+ if ( e . target === e . currentTarget ) {
215+ openContainerInfoSidebar ( unit . id ) ;
216+ }
217+ } , [ openContainerInfoSidebar ] ) ;
218+
210219 return (
211220 < >
212221 < SortableItem
@@ -223,9 +232,15 @@ const UnitCard = ({
223232 background : '#fdfdfd' ,
224233 ...borderStyle ,
225234 } }
235+ onClick = { onClickCard }
226236 >
227237 < div
228- className = { `unit-card ${ isScrolledToElement ? 'highlight' : '' } ` }
238+ className = { classNames ( 'unit-card' ,
239+ {
240+ 'highlight' : isScrolledToElement ,
241+ 'outline-card-selected' : unit . id === selectedContainerId ,
242+ }
243+ ) }
229244 data-testid = "unit-card"
230245 ref = { currentRef }
231246 >
0 commit comments