@@ -43,11 +43,7 @@ export default function Guides({ content }: GuidesInterface) {
4343 useEffect ( ( ) => {
4444 function filterByTags ( ) {
4545 let guides ;
46- if ( searchInput . length === 0 ) {
47- guides = completeGuides ;
48- } else {
49- guides = searchFilteredGuides ;
50- }
46+ guides = completeGuides ;
5147 console . log ( "productFilter" , productFilter ) ;
5248 console . log ( "platformFilter" , platformFilter ) ;
5349 console . log ( "tags" , tags ) ;
@@ -57,7 +53,7 @@ export default function Guides({ content }: GuidesInterface) {
5753 const platFil =
5854 platformFilter . length === 0 || platformFilter . some ( ( tag ) => item . tags . includes ( tag ) ) ;
5955
60- return [ prodFil , platFil ] . every ( ( result ) => result === true ) ;
56+ return [ prodFil , platFil ] . some ( ( result ) => result === true ) ;
6157 } ) ;
6258
6359 setTagFilteredGuides ( guides . sort ( ( a : any , b : any ) => a . order - b . order ) ) ;
@@ -106,14 +102,14 @@ export default function Guides({ content }: GuidesInterface) {
106102 function onChangeSearch ( input ) {
107103 setSearchInput ( input ) ;
108104
109- const inputKeywords = input . trim ( ) . split ( " " ) ;
105+ const inputKeywords = input . trim ( ) . split ( " " ) . filter ( Boolean ) ;
110106
111107 function searchFilter ( item ) {
112108 return (
113- inputKeywords . every ( ( key ) => item . title . toLowerCase ( ) . includes ( key . toLowerCase ( ) ) ) ||
114- inputKeywords . every ( ( key ) => item . description . toLowerCase ( ) . includes ( key . toLowerCase ( ) ) ) ||
115- inputKeywords . every ( ( key ) =>
116- item . tags . map ( ( tag ) => tag . includes ( key . toLowerCase ( ) ) ) . includes ( true ) ,
109+ inputKeywords . some ( ( key ) => item . title . toLowerCase ( ) . includes ( key . toLowerCase ( ) ) ) ||
110+ inputKeywords . some ( ( key ) => item . description . toLowerCase ( ) . includes ( key . toLowerCase ( ) ) ) ||
111+ inputKeywords . some ( ( key ) =>
112+ item . tags . some ( ( tag ) => tag . toLowerCase ( ) . includes ( key . toLowerCase ( ) ) ) ,
117113 )
118114 ) ;
119115 }
0 commit comments