Skip to content

Commit

Permalink
fix(#47): 🐛 fix deletion of name labels in UI
Browse files Browse the repository at this point in the history
fixed behaviour after deleting measurements. Now UI is immediately refreshed, not needing anymore to move the camera position to see the labels of deleted points disappear
  • Loading branch information
franmagn committed Nov 5, 2025
1 parent 7d2fb71 commit e269d39
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/MeasurementControl/measurementsPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -918,9 +918,13 @@ export function initMeasurementsPanel(viewer) {
// Cleanup overlay labels for removed measurements and update positions
try {
// remove overlay labels for uuids that no longer exist
const known = new Set(itemsRaw.map((it) => it.obj.uuid))
const uuidsWithPoints = new Set(
itemsRaw
.filter((it) => it.obj && it.obj.points && it.obj.points.length > 0)
.map((it) => it.obj.uuid)
)
for (const k of Array.from(overlayMap.keys())) {
if (!known.has(k)) {
if (!uuidsWithPoints.has(k)) {
const el = overlayMap.get(k)
if (el && el.parentElement) el.parentElement.removeChild(el)
overlayMap.delete(k)
Expand All @@ -947,6 +951,16 @@ export function initMeasurementsPanel(viewer) {
try {
obj.addEventListener(ev, () => {
rebuildMeasurementList()
// If this object no longer has any points, remove any overlay
// immediately so the on-canvas label doesn't linger.
try {
if (!obj.points || obj.points.length === 0) {
const ol = overlayMap.get(obj.uuid)
if (ol && ol.parentElement) ol.parentElement.removeChild(ol)
overlayMap.delete(obj.uuid)
}
} catch (_e) {}

if (lastSelection.uuid === obj.uuid) {
updateActiveSelection(obj.uuid)
showPanelInMeasurements()
Expand Down Expand Up @@ -1112,6 +1126,13 @@ export function initMeasurementsPanel(viewer) {
scene.removeVolume(obj)
else if (scene.removeProfile && scene.profiles.includes(obj))
scene.removeProfile(obj)
// Remove any on-canvas overlay immediately for this uuid so the
// label doesn't linger while other async updates occur.
try {
const ol = overlayMap.get(obj.uuid)
if (ol && ol.parentElement) ol.parentElement.removeChild(ol)
overlayMap.delete(obj.uuid)
} catch (_e) {}
rebuildMeasurementList()
return
}
Expand Down

0 comments on commit e269d39

Please sign in to comment.