fix: object validation collapsed (#416)

This commit is contained in:
Daniel Lautzenheiser
2023-01-23 14:36:52 -05:00
committed by GitHub
parent dad93b42fc
commit d17378d557
3 changed files with 39 additions and 4 deletions

View File

@ -3,9 +3,13 @@ import { getDataPath } from '@staticcms/core/lib/i18n';
import type { I18nSettings } from '@staticcms/core/interface';
import type { RootState } from '@staticcms/core/store';
export const getEntryDataPath = (i18n: I18nSettings | undefined) => {
return (i18n && getDataPath(i18n.currentLocale, i18n.defaultLocale)) || ['data'];
};
export const selectFieldErrors =
(path: string, i18n: I18nSettings | undefined) => (state: RootState) => {
const dataPath = (i18n && getDataPath(i18n.currentLocale, i18n.defaultLocale)) || ['data'];
const dataPath = getEntryDataPath(i18n);
const fullPath = `${dataPath.join('.')}.${path}`;
return state.entryDraft.fieldsErrors[fullPath] ?? [];
};