@@ -50,6 +50,7 @@ import {
5050 I18N_STRUCTURE ,
5151} from './lib/i18n' ;
5252
53+ import type { StaticallyTypedRecord } from './types/immutable' ;
5354import type { I18nInfo } from './lib/i18n' ;
5455import type AssetProxy from './valueObjects/AssetProxy' ;
5556import type {
@@ -1351,14 +1352,35 @@ export class Backend {
13511352 }
13521353
13531354 filterEntries ( collection : { entries : EntryValue [ ] } , filterRule : FilterRule ) {
1355+ const filterValues = this . valuesAsArray ( filterRule . get ( 'value' ) ) ;
1356+
1357+ const fieldName = filterRule . get ( 'field' ) ;
1358+
13541359 return collection . entries . filter ( entry => {
1355- const fieldValue = entry . data [ filterRule . get ( 'field' ) ] ;
1356- if ( Array . isArray ( fieldValue ) ) {
1357- return fieldValue . includes ( filterRule . get ( 'value' ) ) ;
1358- }
1359- return fieldValue === filterRule . get ( 'value' ) ;
1360+ const fieldValues = this . valuesAsArray ( entry . data [ fieldName ] ) ;
1361+
1362+ return filterValues . some ( filterValue => fieldValues . includes ( filterValue ) ) ;
13601363 } ) ;
13611364 }
1365+
1366+ // Values can be a string, a list of strings, or statically-typed-record lists of strings
1367+ // depending on context (unit test vs. actual config, single vs. multiple values, etc.)
1368+ //
1369+ // We normalize to a simple list for easier processing above.
1370+ //
1371+ valuesAsArray ( rawValue : string | List < string > | StaticallyTypedRecord < List < string > > ) : string [ ] {
1372+ let values : string [ ] = [ ] ;
1373+
1374+ if ( ( < StaticallyTypedRecord < List < string > > > rawValue ) . toJS ) {
1375+ values = ( < StaticallyTypedRecord < List < string > > > rawValue ) . toJS ( ) . toArray ( ) ;
1376+ } else if ( Array . isArray ( rawValue ) ) {
1377+ values = < string [ ] > rawValue ;
1378+ } else {
1379+ values = [ < string > rawValue ] ;
1380+ }
1381+
1382+ return values ;
1383+ }
13621384}
13631385
13641386export function resolveBackend ( config : CmsConfig ) {
0 commit comments