Skip to content

Commit

Permalink
fix: blocks cannot be displayed and updated as expected on reearth/co…
Browse files Browse the repository at this point in the history
…re (#434)

* fix: 3dtiles infobox on reearth/core

* fix: unnecessary render

* fix: entire block feature

* fix: lint
  • Loading branch information
keiya01 authored Feb 7, 2023
1 parent 20382c7 commit b5f921c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/core/Crust/Infobox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export type Props = {
fieldId: string,
value: ValueTypes[T],
type: T,
layer?: Layer,
) => void;
onBlockMove?: (id: string, fromIndex: number, toIndex: number) => void;
onBlockDelete?: (id: string) => void;
Expand Down Expand Up @@ -124,7 +125,7 @@ const Infobox: React.FC<Props> = ({
isEditable={isEditable}
isBuilt={isBuilt}
infoboxProperty={property}
onChange={(...args) => onBlockChange?.(b.id, ...args)}
onChange={(...args) => onBlockChange?.(b.id, ...args, props.layer)}
onClick={() => {
if (b.id && selectedBlockId !== b.id) {
onBlockSelect?.(b.id);
Expand Down
2 changes: 1 addition & 1 deletion src/core/Map/Layers/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ function useSelection({
useEffect(() => {
setSelectedLayer(s =>
s[0]?.layerId && flattenedLayers?.find(l => l.id === s[0]?.layerId)
? s
? [{ ...s[0] }, s[1]] // Force update when flattenedLayers are updated
: !s[0]?.layerId && !s[1]
? s
: [undefined, undefined],
Expand Down
7 changes: 6 additions & 1 deletion src/core/Visualizer/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,12 @@ export default function useHooks({
isEditable: !overriddenInfobox && !!selectedLayer.layer?.layer?.infobox,
visible: !!selectedLayer.layer?.layer?.infobox,
property: selectedLayer.layer?.layer.infobox?.property?.default,
blocks: overridenInfoboxBlocks(overriddenInfobox),
blocks:
overridenInfoboxBlocks(overriddenInfobox) ||
selectedLayer.layer?.layer.infobox?.blocks?.map(b => ({
...b,
property: b.property.default ?? b.property,
})),
}
: undefined,
[selectedLayer, overriddenInfobox],
Expand Down

0 comments on commit b5f921c

Please sign in to comment.