From ff7c5cbcdbe81f4ffec79461e3ba4926f263df05 Mon Sep 17 00:00:00 2001 From: tpluscode Date: Sun, 5 Dec 2021 19:44:37 +0100 Subject: [PATCH] fix: init all props --- .changeset/forty-bees-argue.md | 5 +++++ packages/roadshow/RoadshowController.ts | 6 +++++- packages/roadshow/lib/render.ts | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 .changeset/forty-bees-argue.md diff --git a/.changeset/forty-bees-argue.md b/.changeset/forty-bees-argue.md new file mode 100644 index 0000000..a2a8180 --- /dev/null +++ b/.changeset/forty-bees-argue.md @@ -0,0 +1,5 @@ +--- +"@hydrofoil/roadshow": patch +--- + +Not all properties were initialized to state diff --git a/packages/roadshow/RoadshowController.ts b/packages/roadshow/RoadshowController.ts index 9bfbe1a..e37cd21 100644 --- a/packages/roadshow/RoadshowController.ts +++ b/packages/roadshow/RoadshowController.ts @@ -9,6 +9,7 @@ import { ViewersController } from './ViewersController' import { ShapesController } from './ShapesController' import { ResourcesController } from './ResourcesController' import { ViewContext } from './lib/ViewContext/index' +import { getAllProperties } from './lib/shape' function isFocusNodeState(state: any): state is FocusNodeState { return 'properties' in state && state.properties @@ -71,7 +72,10 @@ export class RoadshowController implements ReactiveController { await this.shapes.loadShapes(state, objects) if (isFocusNodeState(state)) { - state.properties = (state.shape?.property.reduce(createPropertyState, []) || []) + state.properties = [] + if (state.shape) { + state.properties = [...getAllProperties(state.shape)].reduce(createPropertyState, []) + } } delete state.renderer this.host.requestUpdate() diff --git a/packages/roadshow/lib/render.ts b/packages/roadshow/lib/render.ts index 06c460e..89871fb 100644 --- a/packages/roadshow/lib/render.ts +++ b/packages/roadshow/lib/render.ts @@ -19,6 +19,7 @@ import { import type { RoadshowController } from '../RoadshowController' import { isGraphPointer, isLiteral, isResource, TRUE } from './clownface' import { Decorator } from './decorator' +import { getAllProperties } from './shape' export interface RenderFunc> { (this: VC, resource: MultiPointer): TemplateResult | string @@ -130,7 +131,7 @@ function setShape(this: FocusNodeViewContext, shape: NodeShape | ResourceIdentif this.state.applicableViewers = applicableViewers this.state.viewer = viewer - this.state.properties = found.property.reduce(createPropertyState, []) + this.state.properties = [...getAllProperties(found)].reduce(createPropertyState, []) this.controller.host.requestUpdate() } }