diff --git a/script-gen-ui/src/app/components/main-sweep/main-sweep.component.html b/script-gen-ui/src/app/components/main-sweep/main-sweep.component.html
index 323a50b..c4df2a4 100644
--- a/script-gen-ui/src/app/components/main-sweep/main-sweep.component.html
+++ b/script-gen-ui/src/app/components/main-sweep/main-sweep.component.html
@@ -100,8 +100,6 @@
Bias
{
+ this.scrollToPlotInPlotContainer(this.activeComponent!, this.activeIndex!);
+ }, 10);
+ }
}
}
@@ -171,6 +185,11 @@ export class MainSweepComponent implements OnChanges {
componentType: 'bias' | 'step' | 'sweep',
index: number
): void {
+ // Skip scrolling if this is already the active component (clicked again)
+ if (this.isScrolled === true) {
+ return;
+ }
+
let component: BiasComponent | StepComponent | SweepComponent | undefined;
if (componentType === 'bias') {
@@ -188,6 +207,7 @@ export class MainSweepComponent implements OnChanges {
block: 'center', // Align to the center of the viewport
});
}
+ this.isScrolled = true;
}
scrollToPlotInPlotContainer(
@@ -195,7 +215,10 @@ export class MainSweepComponent implements OnChanges {
index: number
): void {
if (this.plotContainer) {
- this.plotContainer.scrollToPlot(componentType, index);
+ // Use setTimeout to ensure scroll happens after any pending view updates
+ setTimeout(() => {
+ this.plotContainer.scrollToPlot(componentType, index);
+ }, 100);
}
}