@@ -385,10 +385,10 @@ export const QuestionFinder = withRouter(({location}: RouteComponentProps) => {
385
385
setSearchDifficulties ( [ ] ) ;
386
386
setSearchTopics ( [ ] ) ;
387
387
setSearchExamBoards ( [ ] ) ;
388
- setSearchStages ( [ ] ) ;
388
+ setSearchStages ( pageContext . stage ? [ pageContext . stage as STAGE ] : [ ] ) ;
389
389
setSearchBooks ( [ ] ) ;
390
390
setExcludeBooks ( false ) ;
391
- setSelections ( [ { } , { } , { } ] ) ;
391
+ setSelections ( [ pageContext . subject ? { "subject" : [ itemiseTag ( tags . getById ( pageContext . subject as TAG_ID ) ) ] } : { } , { } , { } ] ) ;
392
392
setSearchStatuses (
393
393
{
394
394
notAttempted : false ,
@@ -429,19 +429,27 @@ export const QuestionFinder = withRouter(({location}: RouteComponentProps) => {
429
429
430
430
const FilterTag = ( { name} : { name : string } ) => {
431
431
return (
432
- < div className = "tag" >
432
+ < div className = "quiz-level-1- tag me-2 " >
433
433
{ name }
434
434
</ div >
435
435
) ;
436
436
} ;
437
437
438
438
const FilterSummary = ( ) => {
439
- const selectionList : string [ ] = getChoiceTreeLeaves ( selections ) . map ( leaf => leaf . label ) ;
439
+ const stageList : string [ ] = searchStages . filter ( stage => stage !== pageContext . stage ) ;
440
+ const selectionList : string [ ] = getChoiceTreeLeaves ( selections ) . filter ( leaf => leaf . value !== pageContext . subject ) . map ( leaf => leaf . label ) ;
440
441
const statusList : string [ ] = Object . keys ( searchStatuses ) . filter ( status => searchStatuses [ status as keyof QuestionStatus ] ) ;
441
442
442
- const categories = [ searchDifficulties , searchTopics , searchStages , searchExamBoards , statusList , searchBooks , selectionList ] ;
443
+ const categories = [ searchDifficulties , searchTopics , stageList , searchExamBoards , statusList , searchBooks , selectionList ] . flat ( ) ;
443
444
444
- return < div > { categories . map ( c => c . map ( c2 => < FilterTag key = { c2 } name = { c2 } /> ) ) } </ div > ;
445
+ return < div className = "d-flex" >
446
+ { categories . map ( c => < FilterTag key = { c } name = { c } /> ) }
447
+ { categories . length > 0 ?
448
+ < button className = "text-black py-0 btn-link bg-transparent" onClick = { ( e ) => { e . stopPropagation ( ) ; clearFilters ( ) ; } } >
449
+ clear all filters
450
+ </ button >
451
+ : < div /> }
452
+ </ div > ;
445
453
} ;
446
454
447
455
return < Container id = "finder-page" className = { classNames ( "mb-5" ) } { ...( pageContext ?. subject && { "data-bs-theme" : pageContext . subject } ) } >
@@ -498,7 +506,7 @@ export const QuestionFinder = withRouter(({location}: RouteComponentProps) => {
498
506
</ Col >
499
507
</ Row > }
500
508
501
- < FilterSummary />
509
+ { isPhy && < FilterSummary /> }
502
510
503
511
< Row className = "mt-4 position-relative finder-panel" >
504
512
< Col lg = { siteSpecific ( 4 , 3 ) } md = { 12 } xs = { 12 } className = { classNames ( "text-wrap my-2" , { "d-none" : isPhy } ) } data-testid = "question-finder-filters" >
0 commit comments