reearth / resium

React components for 🌏 Cesium
https://resium.reearth.io
MIT License
727 stars 134 forks source link

EntityDescription is not rendered if second entity is clicked #628

Closed michfarmer closed 2 months ago

michfarmer commented 1 year ago

We noticed that if we click an Entity, and then immediately click another one, the EntityDescription is not rendered.

Looking at https://resium.reearth.io/examples/?path=/story/entity--description it seems that this example exhibits a similar behavior.

Clicking each entity in turn may or may not load the EntityDescription. Sometimes it does, sometimes it doesn't.

missingEntityDescription

michfarmer commented 12 months ago

I believe it has something to do with this line:

https://github.com/reearth/resium/blob/main/src/EntityDescription/EntityDescription.ts#L69

When you click on a second entity while the infobox is active, the classList no longer contains cesium-infoBox-bodyless, which means it cannot find the node.

jakedarby24 commented 11 months ago

I've been noticing this problem as well, and it's preventing me from upgrading to 1.17.2 from 1.16.1. If this could be looked into it would be amazing

Earthling7235 commented 11 months ago

I'm getting this as well. We are dealing with it for now by flagging it as known behavior for now. Would love this to work as intended.

mfarmer-ara commented 9 months ago

I spent a little time today figuring out a workaround to inject the class that it wants. It's not ideal but it seems to work for my purposes until the fix is accepted.

I put the following in the onSelectedEntityChange parameter on <Viewer. Change your ref as needed.

onSelectedEntityChange={(selectedEntity) => {
  if (selectedEntity && !selectedEntity?.description) {
    const container = refViewer?.current?.cesiumElement?.infoBox?.container;
    const node = container.querySelector('.cesium-infoBox');
    node.classList.add('cesium-infoBox-bodyless');
  }
}