From 974cd1a41e3d689df722c91f4512779fb9313e5d Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Mon, 25 Sep 2023 14:18:07 -0400 Subject: [PATCH] fixed annotation list scroll position resetting when selecting an annotation --- src/neuroglancer/ui/annotations.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/neuroglancer/ui/annotations.ts b/src/neuroglancer/ui/annotations.ts index 1126ed0f9..8028dcfe1 100644 --- a/src/neuroglancer/ui/annotations.ts +++ b/src/neuroglancer/ui/annotations.ts @@ -562,8 +562,12 @@ export class AnnotationLayerView extends Tab { } const oldLength = this.virtualListSource.length; this.updateListLength(); + // TODO, what problems does this change cause? + const insertCount = Math.max(0, listElements.length - oldLength); + const deleteCount = Math.max(0, oldLength - listElements.length); + const retainCount = Math.min(listElements.length, oldLength); this.virtualListSource.changed!.dispatch( - [{retainCount: 0, deleteCount: oldLength, insertCount: listElements.length}]); + [{retainCount, deleteCount, insertCount}]); this.mutableControls.style.display = isMutable ? 'contents' : 'none'; this.resetOnUpdate(); }