@@ -26,6 +26,28 @@ export default function SearchTabFilters({ locations, achievements }) {
26
26
const [ locationsData , setLocationsData ] = useState ( locations ) ;
27
27
const [ achievementsData , setAchievementsData ] = useState ( achievements ) ;
28
28
29
+ /**
30
+ * Component unmount trigger
31
+ */
32
+ useEffect ( ( ) => {
33
+ return ( ) => {
34
+ console . log ( "filters unmounted..." ) ;
35
+ handleReset ( ) ;
36
+ } ;
37
+ } , [ ] ) ;
38
+
39
+ const handleReset = ( ) => {
40
+ search . selectLocations ( [ ] ) ;
41
+ search . selectSkills ( [ ] ) ;
42
+ search . selectAchievements ( [ ] ) ;
43
+ search . selectAvailability ( {
44
+ isAvailableSelected : false ,
45
+ isUnavailableSelected : false ,
46
+ } ) ;
47
+ search . selectCompanyAttributes ( { } ) ;
48
+ search . changePageNumber ( 1 ) ;
49
+ } ;
50
+
29
51
useEffect ( ( ) => {
30
52
setLocationsData ( locations ) ;
31
53
setAchievementsData ( achievements ) ;
@@ -202,7 +224,10 @@ export default function SearchTabFilters({ locations, achievements }) {
202
224
203
225
return (
204
226
< div className = { styles . searchTabFilters } >
205
- < Summary filtersApplied = { numberOfFiltersApplied } />
227
+ < Summary
228
+ filtersApplied = { numberOfFiltersApplied }
229
+ handleReset = { handleReset }
230
+ />
206
231
{ search . isFilterActive ( FILTERS . LOCATIONS ) && (
207
232
< div className = { utilityStyles . mt32 } >
208
233
< Collapsible title = "Location" collapsed = { false } >
@@ -302,21 +327,8 @@ SearchTabFilters.propTypes = {
302
327
achievements : PT . array ,
303
328
} ;
304
329
305
- function Summary ( { filtersApplied } ) {
330
+ function Summary ( { filtersApplied, handleReset } ) {
306
331
const search = useSearch ( ) ;
307
-
308
- const handleReset = ( ) => {
309
- search . selectLocations ( [ ] ) ;
310
- search . selectSkills ( [ ] ) ;
311
- search . selectAchievements ( [ ] ) ;
312
- search . selectAvailability ( {
313
- isAvailableSelected : false ,
314
- isUnavailableSelected : false ,
315
- } ) ;
316
- search . selectCompanyAttributes ( { } ) ;
317
- search . changePageNumber ( 1 ) ;
318
- } ;
319
-
320
332
return (
321
333
< div className = { styles . searchTabFiltersSummary } >
322
334
< div className = { styles . searchTabFiltersSummaryTextContainer } >
0 commit comments