From e78c8d643112efa2fbcc55efe63d3187214f51de Mon Sep 17 00:00:00 2001 From: Teodor Voicu Date: Wed, 26 Jul 2023 02:25:05 +0300 Subject: [PATCH] fix: save selected value, broken styling --- .../manage/Widgets/GeolocationWidget.jsx | 46 +++++++++++++------ 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/src/components/manage/Widgets/GeolocationWidget.jsx b/src/components/manage/Widgets/GeolocationWidget.jsx index f24e8cc..54ed430 100644 --- a/src/components/manage/Widgets/GeolocationWidget.jsx +++ b/src/components/manage/Widgets/GeolocationWidget.jsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import PropTypes from 'prop-types'; -import { Grid, Button, Segment } from 'semantic-ui-react'; +import { Grid, Button } from 'semantic-ui-react'; import { defineMessages, injectIntl } from 'react-intl'; import { useSelector, useDispatch } from 'react-redux'; import { FormFieldWrapper, Icon, SidebarPopup } from '@plone/volto/components'; @@ -77,7 +77,16 @@ const GeolocationWidget = (props) => { : countryGroups; }; - const handleGroupChange = ({ label, value }) => { + const handleGroupChange = (selectedOption) => { + if (!selectedOption) { + onChange(id, { + ...originalValue, + geolocation: [], + selectedGroup: null, + }); + return; + } + const { label, value } = selectedOption; let arr = []; if (isEmpty(geotags)) { arr = eeaCountries.filter((item) => item.group?.includes(label)); @@ -102,6 +111,7 @@ const GeolocationWidget = (props) => { onChange(id, { ...originalValue, geolocation: getOptions(originalValue.geolocation, arr), + selectedGroup: selectedOption, }); }; @@ -144,7 +154,6 @@ const GeolocationWidget = (props) => {