From 530c8de75c6e8ae7d8cb28d8b9df9025cb647ddd Mon Sep 17 00:00:00 2001 From: Jessica McInchak Date: Tue, 3 Sep 2024 12:41:08 +0200 Subject: [PATCH] fix map field reset & closed tabs bugs --- .../src/@planx/components/MapAndLabel/Public/Context.tsx | 4 +--- .../components/shared/Schema/InputFields/MapFieldInput.tsx | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/editor.planx.uk/src/@planx/components/MapAndLabel/Public/Context.tsx b/editor.planx.uk/src/@planx/components/MapAndLabel/Public/Context.tsx index 167c608cde..82440d9edd 100644 --- a/editor.planx.uk/src/@planx/components/MapAndLabel/Public/Context.tsx +++ b/editor.planx.uk/src/@planx/components/MapAndLabel/Public/Context.tsx @@ -93,9 +93,7 @@ export const MapAndLabelProvider: React.FC = ( }, }); - const [activeIndex, setActiveIndex] = useState( - props.previouslySubmittedData ? -1 : 0, - ); + const [activeIndex, setActiveIndex] = useState(0); const [minError, setMinError] = useState(false); const [maxError, setMaxError] = useState(false); diff --git a/editor.planx.uk/src/@planx/components/shared/Schema/InputFields/MapFieldInput.tsx b/editor.planx.uk/src/@planx/components/shared/Schema/InputFields/MapFieldInput.tsx index a374faa5a7..4b9dcb8181 100644 --- a/editor.planx.uk/src/@planx/components/shared/Schema/InputFields/MapFieldInput.tsx +++ b/editor.planx.uk/src/@planx/components/shared/Schema/InputFields/MapFieldInput.tsx @@ -21,7 +21,7 @@ export const MapFieldInput: React.FC> = (props) => { const editableFeatures = props.formik.values.schemaData?.[props.activeIndex] ?.features as Feature[]; const [features, setFeatures] = useState( - editableFeatures.length > 0 ? editableFeatures : undefined, + editableFeatures?.length > 0 ? editableFeatures : undefined, ); useEffect(() => {