@@ -5,6 +5,7 @@ import { faExternalLink } from "@fortawesome/pro-regular-svg-icons";
55import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" ;
66import { AppContext } from "../containers/AppContext" ;
77import { libraryFormatter } from "../libs/utils" ;
8+ import "./ImageCollections.css" ;
89
910const { Title, Paragraph } = Typography ;
1011
@@ -154,27 +155,41 @@ export default function ImageCollections() {
154155 } ) )
155156 . filter ( ( collection ) => collection . releaseRows . length > 0 ) ;
156157
157- // Group the dropdown options by collection type (e.g. Light Microscopy /
158- // Electron Microscopy) when a type is provided, otherwise show a flat list.
158+ // Render a dropdown option showing the collection name (in bold) above its
159+ // description, so users see what each collection contains without having to
160+ // parse the name first. `label` is the plain name, used for the selected
161+ // value display (via optionLabelProp) and for search filtering.
162+ const renderCollectionOption = ( collection ) => (
163+ < Select . Option
164+ key = { collection . name }
165+ value = { collection . name }
166+ label = { collection . name }
167+ >
168+ < div className = "collection-option" >
169+ < span className = "collection-option-name" > { collection . name } </ span >
170+ { collection . description ? (
171+ < span className = "collection-option-description" >
172+ { collection . description }
173+ </ span >
174+ ) : null }
175+ </ div >
176+ </ Select . Option >
177+ ) ;
178+
179+ // Group the collections by type (e.g. Light Microscopy / Electron
180+ // Microscopy) when a type is provided, otherwise show a flat list.
159181 const hasTypes = collections . some ( ( collection ) => collection . type ) ;
160- let collectionOptions ;
182+ const collectionGroups = [ ] ;
161183 if ( hasTypes ) {
162- const groups = [ ] ;
163184 collections . forEach ( ( collection ) => {
164185 const groupLabel = collection . type || "Other" ;
165- let group = groups . find ( ( g ) => g . label === groupLabel ) ;
186+ let group = collectionGroups . find ( ( entry ) => entry . label === groupLabel ) ;
166187 if ( ! group ) {
167- group = { label : groupLabel , options : [ ] } ;
168- groups . push ( group ) ;
188+ group = { label : groupLabel , items : [ ] } ;
189+ collectionGroups . push ( group ) ;
169190 }
170- group . options . push ( { value : collection . name , label : collection . name } ) ;
191+ group . items . push ( collection ) ;
171192 } ) ;
172- collectionOptions = groups ;
173- } else {
174- collectionOptions = collections . map ( ( collection ) => ( {
175- value : collection . name ,
176- label : collection . name ,
177- } ) ) ;
178193 }
179194
180195 // Default to the first collection until the user picks one.
@@ -262,14 +277,28 @@ export default function ImageCollections() {
262277 < Select
263278 id = "collection-select"
264279 value = { activeCollection ? activeCollection . name : undefined }
265- options = { collectionOptions }
266280 onChange = { ( value ) => setSelectedCollection ( value ) }
267- style = { { minWidth : 320 } }
268- listHeight = { 400 }
281+ style = { { width : 460 , maxWidth : "100%" } }
282+ listHeight = { 560 }
283+ virtual = { false }
284+ popupClassName = "collection-select-dropdown"
269285 showSearch
270286 optionFilterProp = "label"
287+ optionLabelProp = "label"
271288 placeholder = "Select a collection"
272- />
289+ >
290+ { hasTypes
291+ ? collectionGroups . map ( ( group ) => (
292+ < Select . OptGroup key = { group . label } label = { group . label } >
293+ { group . items . map ( ( collection ) =>
294+ renderCollectionOption ( collection ) ,
295+ ) }
296+ </ Select . OptGroup >
297+ ) )
298+ : collections . map ( ( collection ) =>
299+ renderCollectionOption ( collection ) ,
300+ ) }
301+ </ Select >
273302 </ Paragraph >
274303 { activeCollection ? (
275304 < >
0 commit comments