From aa5551623ebb44d0091bbad3f40cac6a1e87215a Mon Sep 17 00:00:00 2001 From: "O.Bilenko" Date: Tue, 9 Apr 2019 10:33:40 +0200 Subject: [PATCH] PWA-1834 Possible to vertical scroll adress form because of long province name --- libraries/ui-shared/Form/Builder/index.jsx | 11 +++++++++ .../ui-shared/Form/Builder/iso-3166-2.js | 24 +++++++++---------- .../Form/Select/__snapshots__/spec.jsx.snap | 6 ++--- libraries/ui-shared/Form/Select/style.js | 3 +++ 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/libraries/ui-shared/Form/Builder/index.jsx b/libraries/ui-shared/Form/Builder/index.jsx index f3eb992952..8e61f9a75f 100644 --- a/libraries/ui-shared/Form/Builder/index.jsx +++ b/libraries/ui-shared/Form/Builder/index.jsx @@ -112,6 +112,17 @@ class Builder extends Component { const countryElement = this.formElements.find(el => el.type === ELEMENT_TYPE_COUNTRY); if (countryElement) { this.countryList = buildCountryList(countryElement, emptySelectOption); + const provinceElement = this.formElements.find(el => el.type === ELEMENT_TYPE_PROVINCE); + if (provinceElement + && provinceElement.required + && !!formDefaults[countryElement.id] + && !formDefaults[provinceElement.id]) { + // Set default for province field for given country + const [first] = Object.values(buildProvinceList(formDefaults[countryElement.id])); + if (first) { + this.state.formData[provinceElement.id] = first; + } + } } // Final form initialization, by triggering actionListeners and enable rendering for elements diff --git a/libraries/ui-shared/Form/Builder/iso-3166-2.js b/libraries/ui-shared/Form/Builder/iso-3166-2.js index ece38110da..c7b47ad372 100644 --- a/libraries/ui-shared/Form/Builder/iso-3166-2.js +++ b/libraries/ui-shared/Form/Builder/iso-3166-2.js @@ -435,19 +435,17 @@ export default { BE: { name: 'Belgium', divisions: { - 'BRU': 'Bruxelles-Capitale, Region de (fr), Brussels Hoofdstedelijk Gewest (nl)', - 'VLG': 'Vlaamse Gewest (nl)', - 'VAN': 'Antwerpen (nl)', - 'VLI': 'Limburg (nl)', - 'VOV': 'Oost-Vlaanderen (nl)', - 'VBR': 'Vlaams Brabant (nl)', - 'VWV': 'West-Vlaanderen (nl)', - 'WAL': 'Wallonne, Region (fr)', - 'WBR': 'Brabant Wallon (fr)', - 'WHT': 'Hainaut (fr)', - 'WLG': 'Liège (fr)', - 'WLX': 'Luxembourg (fr)', - 'WNA': 'Namur (fr)', + 'BRU': 'Brussels', + 'VAN': 'Antwerpen', + 'VLI': 'Limburg', + 'VOV': 'Oost-Vlaanderen', + 'VBR': 'Vlaams Brabant', + 'VWV': 'West-Vlaanderen', + 'WBR': 'Brabant Wallon', + 'WHT': 'Hainaut', + 'WLG': 'Liège', + 'WLX': 'Luxembourg', + 'WNA': 'Namur', }, }, BZ: { diff --git a/libraries/ui-shared/Form/Select/__snapshots__/spec.jsx.snap b/libraries/ui-shared/Form/Select/__snapshots__/spec.jsx.snap index 1dc44e8b49..ef1f0331f2 100644 --- a/libraries/ui-shared/Form/Select/__snapshots__/spec.jsx.snap +++ b/libraries/ui-shared/Form/Select/__snapshots__/spec.jsx.snap @@ -66,7 +66,7 @@ exports[` should render select with 2 options 1`] = `