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 ) ;
@@ -213,6 +216,12 @@ const UnitCard = ({
213216 && ! subsection . upstreamInfo ?. upstreamRef
214217 ) ;
215218
219+ const onClickCard = useCallback ( ( e : React . MouseEvent ) => {
220+ if ( e . target === e . currentTarget ) {
221+ openContainerInfoSidebar ( unit . id ) ;
222+ }
223+ } , [ openContainerInfoSidebar ] ) ;
224+
216225 return (
217226 < >
218227 < SortableItem
@@ -229,9 +238,15 @@ const UnitCard = ({
229238 background : '#fdfdfd' ,
230239 ...borderStyle ,
231240 } }
241+ onClick = { onClickCard }
232242 >
233243 < div
234- className = { `unit-card ${ isScrolledToElement ? 'highlight' : '' } ` }
244+ className = { classNames ( 'unit-card' ,
245+ {
246+ 'highlight' : isScrolledToElement ,
247+ 'outline-card-selected' : unit . id === selectedContainerId ,
248+ }
249+ ) }
235250 data-testid = "unit-card"
236251 ref = { currentRef }
237252 >
0 commit comments