diff --git a/packages/core/src/backend.ts b/packages/core/src/backend.ts index fda2fd4c..eef2adcf 100644 --- a/packages/core/src/backend.ts +++ b/packages/core/src/backend.ts @@ -1005,17 +1005,15 @@ export class Backend f!.name) ?? []; - } else { - const files = collection.files ?? []; - const file: CollectionFile | null = files.filter(f => f!.name === entry.slug)?.[0] ?? null; - - if (file == null) { - throw new Error(`No file found for ${entry.slug} in ${collection.name}`); - } - return file.fields.map(f => f.name); } - return []; + const files = collection.files ?? []; + const file: CollectionFile | null = files.filter(f => f!.name === entry.slug)?.[0] ?? null; + + if (file == null) { + throw new Error(`No file found for ${entry.slug} in ${collection.name}`); + } + return file.fields.map(f => f.name); } filterEntries(collection: { entries: Entry[] }, filterRule: FilterRule) { diff --git a/packages/core/src/components/collections/FilterControl.tsx b/packages/core/src/components/collections/FilterControl.tsx index 7340d87f..1900364b 100644 --- a/packages/core/src/components/collections/FilterControl.tsx +++ b/packages/core/src/components/collections/FilterControl.tsx @@ -25,6 +25,7 @@ const FilterControl = ({ const handleFilterClick = useCallback( (viewFilter: ViewFilter) => (event: MouseEvent | ChangeEvent) => { event.stopPropagation(); + event.preventDefault(); onFilterClick(viewFilter); }, [onFilterClick], diff --git a/packages/core/src/components/collections/entries/EntriesCollection.tsx b/packages/core/src/components/collections/entries/EntriesCollection.tsx index bbb65bf8..d20ae325 100644 --- a/packages/core/src/components/collections/entries/EntriesCollection.tsx +++ b/packages/core/src/components/collections/entries/EntriesCollection.tsx @@ -71,7 +71,6 @@ const EntriesCollection = ({ const [prevCollection, setPrevCollection] = useState(collection); const groups = useGroups(collection.name); - console.log('[GROUPS] groups', groups); const entries = useEntries(collection); diff --git a/packages/core/src/lib/hooks/useFilters.ts b/packages/core/src/lib/hooks/useFilters.ts index d1a177a9..cf63cbb0 100644 --- a/packages/core/src/lib/hooks/useFilters.ts +++ b/packages/core/src/lib/hooks/useFilters.ts @@ -1,14 +1,14 @@ import { useMemo } from 'react'; -import { selectEntriesSortField } from '@staticcms/core/reducers/selectors/entries'; +import { selectEntriesFilter } from '@staticcms/core/reducers/selectors/entries'; import { useAppSelector } from '@staticcms/core/store/hooks'; export default function useFilters(collectionName: string) { - const entriesSortFieldSelector = useMemo( - () => selectEntriesSortField(collectionName), + const entriesFilterFieldSelector = useMemo( + () => selectEntriesFilter(collectionName), [collectionName], ); - const filters = useAppSelector(entriesSortFieldSelector); + const filters = useAppSelector(entriesFilterFieldSelector); return useMemo(() => { return Object.values(filters ?? {}).filter(v => v?.active === true) || [];