Skip to content

Commit

Permalink
fix: init all props
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode committed Dec 5, 2021
1 parent 6edf7c5 commit ff7c5cb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/forty-bees-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hydrofoil/roadshow": patch
---

Not all properties were initialized to state
6 changes: 5 additions & 1 deletion packages/roadshow/RoadshowController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion packages/roadshow/lib/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<VC extends ViewContext<unknown>> {
(this: VC, resource: MultiPointer): TemplateResult | string
Expand Down Expand Up @@ -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()
}
}
Expand Down

0 comments on commit ff7c5cb

Please sign in to comment.