Skip to content

Commit

Permalink
🐛 Handle missing component translations more gracefully
Browse files Browse the repository at this point in the history
The exception-throwing approach breaks the open-forms E2E integration tests by
crashing the form builder.
  • Loading branch information
sergei-maertens committed Sep 7, 2023
1 parent 993bfea commit 7b46b73
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/components/builder/validate/i18n.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ export function useManageValidatorsTranslations<S extends SchemaWithValidation>(

// set any missing translations
useEffect(() => {
if (!value) {
throw new Error('Missing default (Formik) value for `translatedErrors`!');
}
const newValue = {...value};
const newValue = value
? {...value}
: (Object.fromEntries(supportedLanguageCodes.map(code => [code, {}])) as NonNullable<
S['translatedErrors']
>);
const emptyDefaults = Object.fromEntries(keys.map(k => [k, '']));
for (const code of supportedLanguageCodes) {
newValue[code] = {...emptyDefaults, ...newValue[code]};
Expand Down

0 comments on commit 7b46b73

Please sign in to comment.