From 4b1e1682c8c413dbc6e4e026e7cc05795265bd76 Mon Sep 17 00:00:00 2001 From: Dan Ribbens Date: Tue, 22 Oct 2019 21:38:55 -0400 Subject: [PATCH] localization plugin no longer mishandling schema type String as an array --- demo/content-blocks/CallToAction.js | 4 ++-- src/localization/localization.plugin.js | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/demo/content-blocks/CallToAction.js b/demo/content-blocks/CallToAction.js index 8c1e25b3fd..ea9b7849fd 100644 --- a/demo/content-blocks/CallToAction.js +++ b/demo/content-blocks/CallToAction.js @@ -3,8 +3,8 @@ module.exports = { label: 'CTA', fields: [ { - name: 'title', - label: 'Title', + name: 'label', + label: 'Label', type: 'input', localized: true, maxLength: 100, diff --git a/src/localization/localization.plugin.js b/src/localization/localization.plugin.js index 37a7737f9d..16c70511ec 100644 --- a/src/localization/localization.plugin.js +++ b/src/localization/localization.plugin.js @@ -149,13 +149,11 @@ export default function localizationPlugin(schema, options) { } this.fallbackLocale = fallbackLocale; this.schema.eachPath((path, schemaType) => { - const isArrayOfReferences = schemaType.options.type && schemaType.options.type[0]; - const isReference = schemaType.options.ref; - if (isArrayOfReferences) { + if (schemaType.options.type instanceof Array) { this[path].forEach(doc => doc.setLocale && doc.setLocale(locale, fallbackLocale)); } - if (isReference && this[path]) { + if (schemaType.options.ref && this[path]) { this[path].setLocale && this[path].setLocale(locale, fallbackLocale); } })