fix: various fixes and tweaks (#701)
This commit is contained in:
committed by
GitHub
parent
422b7798da
commit
364612e9ae
@ -185,10 +185,12 @@ function entryDraftReducer(
|
||||
}
|
||||
|
||||
case DRAFT_VALIDATION_ERRORS: {
|
||||
const { path, errors, i18n } = action.payload;
|
||||
const { path, errors, i18n, isMeta } = action.payload;
|
||||
const fieldsErrors = { ...state.fieldsErrors };
|
||||
|
||||
const dataPath = (i18n && getDataPath(i18n.currentLocale, i18n.defaultLocale)) || ['data'];
|
||||
const dataPath = isMeta
|
||||
? ['meta']
|
||||
: (i18n && getDataPath(i18n.currentLocale, i18n.defaultLocale)) || ['data'];
|
||||
const fullPath = `${dataPath.join('.')}.${path}`;
|
||||
|
||||
if (errors.length === 0) {
|
||||
|
@ -3,13 +3,16 @@ 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 getEntryDataPath = (i18n: I18nSettings | undefined, isMeta: boolean | undefined) => {
|
||||
return isMeta
|
||||
? ['meta']
|
||||
: (i18n && getDataPath(i18n.currentLocale, i18n.defaultLocale)) || ['data'];
|
||||
};
|
||||
|
||||
export const selectFieldErrors =
|
||||
(path: string, i18n: I18nSettings | undefined) => (state: RootState) => {
|
||||
const dataPath = getEntryDataPath(i18n);
|
||||
(path: string, i18n: I18nSettings | undefined, isMeta: boolean | undefined) =>
|
||||
(state: RootState) => {
|
||||
const dataPath = getEntryDataPath(i18n, isMeta);
|
||||
const fullPath = `${dataPath.join('.')}.${path}`;
|
||||
return state.entryDraft.fieldsErrors[fullPath] ?? [];
|
||||
};
|
||||
|
Reference in New Issue
Block a user