Skip to content

Commit 57bc6ae

Browse files
authored
Ensure that component_list_ui uses unique id for its list_item_scope (#9392)
### Related * Fixes #9391 * Exposed by #9381 ### What The new property UI would call multiple `EntityPath::data_ui` sequentially. These would lead to `component_list_ui` to be called, and because they had a hard-coded id, there would be cross-talk between the scopes' underlying egui memory storage. This PR makes the id unique.
1 parent 5830bd2 commit 57bc6ae

File tree

1 file changed

+80
-75
lines changed

1 file changed

+80
-75
lines changed

crates/viewer/re_data_ui/src/instance_path.rs

Lines changed: 80 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -180,85 +180,90 @@ fn component_list_ui(
180180

181181
let interactive = ui_layout != UiLayout::Tooltip;
182182

183-
re_ui::list_item::list_item_scope(ui, "component list", |ui| {
184-
for (component_name, unit) in components {
185-
let component_name = *component_name;
186-
if !show_indicator_comps && component_name.is_indicator_component() {
187-
continue;
188-
}
183+
re_ui::list_item::list_item_scope(
184+
ui,
185+
egui::Id::from("component list").with(entity_path),
186+
|ui| {
187+
for (component_name, unit) in components {
188+
let component_name = *component_name;
189+
if !show_indicator_comps && component_name.is_indicator_component() {
190+
continue;
191+
}
189192

190-
let component_path = ComponentPath::new(entity_path.clone(), component_name);
191-
let is_static = db
192-
.storage_engine()
193-
.store()
194-
.entity_has_static_component(entity_path, &component_name);
195-
let icon = if is_static {
196-
&re_ui::icons::COMPONENT_STATIC
197-
} else {
198-
&re_ui::icons::COMPONENT_TEMPORAL
199-
};
200-
let item = Item::ComponentPath(component_path);
201-
202-
let mut list_item = ui.list_item().interactive(interactive);
203-
204-
if interactive {
205-
let is_hovered = ctx.selection_state().highlight_for_ui_element(&item)
206-
== HoverHighlight::Hovered;
207-
list_item = list_item.force_hovered(is_hovered);
208-
}
193+
let component_path = ComponentPath::new(entity_path.clone(), component_name);
194+
let is_static = db
195+
.storage_engine()
196+
.store()
197+
.entity_has_static_component(entity_path, &component_name);
198+
let icon = if is_static {
199+
&re_ui::icons::COMPONENT_STATIC
200+
} else {
201+
&re_ui::icons::COMPONENT_TEMPORAL
202+
};
203+
let item = Item::ComponentPath(component_path);
209204

210-
let response = if component_name.is_indicator_component() {
211-
list_item.show_flat(
212-
ui,
213-
re_ui::list_item::LabelContent::new(component_name.short_name())
214-
.with_icon(icon),
215-
)
216-
} else {
217-
let content = re_ui::list_item::PropertyContent::new(component_name.short_name())
218-
.with_icon(icon)
219-
.value_fn(|ui, _| {
220-
if instance.is_all() {
221-
crate::ComponentPathLatestAtResults {
222-
component_path: ComponentPath::new(
223-
entity_path.clone(),
224-
component_name,
225-
),
226-
unit,
227-
}
228-
.data_ui(
229-
ctx,
230-
ui,
231-
UiLayout::List,
232-
query,
233-
db,
234-
);
235-
} else {
236-
ctx.component_ui_registry().ui(
237-
ctx,
238-
ui,
239-
UiLayout::List,
240-
query,
241-
db,
242-
entity_path,
243-
component_name,
244-
unit,
245-
instance,
246-
);
247-
}
248-
});
249-
250-
list_item.show_flat(ui, content)
251-
};
252-
253-
let response = response.on_hover_ui(|ui| {
254-
component_name.data_ui_recording(ctx, ui, UiLayout::Tooltip);
255-
});
205+
let mut list_item = ui.list_item().interactive(interactive);
256206

257-
if interactive {
258-
ctx.handle_select_hover_drag_interactions(&response, item, false);
207+
if interactive {
208+
let is_hovered = ctx.selection_state().highlight_for_ui_element(&item)
209+
== HoverHighlight::Hovered;
210+
list_item = list_item.force_hovered(is_hovered);
211+
}
212+
213+
let response = if component_name.is_indicator_component() {
214+
list_item.show_flat(
215+
ui,
216+
re_ui::list_item::LabelContent::new(component_name.short_name())
217+
.with_icon(icon),
218+
)
219+
} else {
220+
let content =
221+
re_ui::list_item::PropertyContent::new(component_name.short_name())
222+
.with_icon(icon)
223+
.value_fn(|ui, _| {
224+
if instance.is_all() {
225+
crate::ComponentPathLatestAtResults {
226+
component_path: ComponentPath::new(
227+
entity_path.clone(),
228+
component_name,
229+
),
230+
unit,
231+
}
232+
.data_ui(
233+
ctx,
234+
ui,
235+
UiLayout::List,
236+
query,
237+
db,
238+
);
239+
} else {
240+
ctx.component_ui_registry().ui(
241+
ctx,
242+
ui,
243+
UiLayout::List,
244+
query,
245+
db,
246+
entity_path,
247+
component_name,
248+
unit,
249+
instance,
250+
);
251+
}
252+
});
253+
254+
list_item.show_flat(ui, content)
255+
};
256+
257+
let response = response.on_hover_ui(|ui| {
258+
component_name.data_ui_recording(ctx, ui, UiLayout::Tooltip);
259+
});
260+
261+
if interactive {
262+
ctx.handle_select_hover_drag_interactions(&response, item, false);
263+
}
259264
}
260-
}
261-
});
265+
},
266+
);
262267
}
263268

264269
/// If this entity is an image, show it together with buttons to download and copy the image.

0 commit comments

Comments
 (0)