diff --git a/web/src/beta/lib/core/Crust/Infobox/Block/builtin/useExpressionEval.ts b/web/src/beta/lib/core/Crust/Infobox/Block/builtin/useExpressionEval.ts index b068b5fe28..6ea947564d 100644 --- a/web/src/beta/lib/core/Crust/Infobox/Block/builtin/useExpressionEval.ts +++ b/web/src/beta/lib/core/Crust/Infobox/Block/builtin/useExpressionEval.ts @@ -8,6 +8,8 @@ export default (value: unknown | undefined) => { const [isReady, setIsReady] = useState(false); const [currentValue, setCurrentValue] = useState(value); + const [lastFeatureSelected, setLastFeatureSelected] = useState(undefined); + const [evaluatedResult, setEvaluatedResult] = useState(undefined); const visualizer = useVisualizer(); @@ -25,7 +27,10 @@ export default (value: unknown | undefined) => { return; } const selectedFeature = visualizer.current?.layers.selectedFeature(); - if (selectedFeature) { + if (selectedFeature && selectedFeature.id !== lastFeatureSelected) { + setLastFeatureSelected(selectedFeature.id); + setEvaluatedResult(undefined); + } else if (selectedFeature) { const simpleFeature: Feature = { id: selectedFeature.id, type: "feature", diff --git a/web/src/beta/lib/core/Crust/Infobox/hooks.ts b/web/src/beta/lib/core/Crust/Infobox/hooks.ts index c4477bf099..9c13aba8a9 100644 --- a/web/src/beta/lib/core/Crust/Infobox/hooks.ts +++ b/web/src/beta/lib/core/Crust/Infobox/hooks.ts @@ -24,11 +24,14 @@ export default ({ const [selectedBlockId, setSelectedBlockId] = useState(); const [openBlocksIndex, setOpenBlocksIndex] = useState(); + // Will only be undefined when infobox is first created, so default to true const showInfobox = useMemo( () => - infobox?.property?.default?.enabled?.value === undefined - ? false - : !!infobox.property.default.enabled.value, + infobox + ? infobox?.property?.default?.enabled?.value === undefined + ? true + : !!infobox.property.default.enabled.value + : false, [infobox], );