From 5f66f4dc415e3e7570f856a9b4b28f54615afe9e Mon Sep 17 00:00:00 2001
From: Pierre Ecarlat <pecarlat@grandlyon.com>
Date: Wed, 19 Mar 2025 08:15:43 +0100
Subject: [PATCH] fix: focus on top happens only after navigation

---
 .../orientation-form-view.component.ts              | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/app/form/orientation-form-view/orientation-form-view.component.ts b/src/app/form/orientation-form-view/orientation-form-view.component.ts
index bd5c4d59d..939508682 100644
--- a/src/app/form/orientation-form-view/orientation-form-view.component.ts
+++ b/src/app/form/orientation-form-view/orientation-form-view.component.ts
@@ -162,10 +162,6 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked
 
   public validatePage(event: boolean): void {
     this.isPageValid = event;
-    const mainHeader = document.querySelector('#pageTitle');
-    if (mainHeader) {
-      (mainHeader as HTMLElement)?.focus();
-    }
   }
 
   public setFailedOrientation(): void {
@@ -263,6 +259,7 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked
     this.updateHiddenNavButtons();
     this.updateFullScreen();
     this.updateLastStep();
+    this.focusOnTop();
   }
 
   public prevPage(): void {
@@ -278,6 +275,7 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked
     this.updateHiddenNavButtons();
     this.updateFullScreen();
     this.updateLastStep();
+    this.focusOnTop();
   }
 
   private goToNextStep(): void {
@@ -437,6 +435,13 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked
     this.filters = [];
   }
 
+  private focusOnTop(): void {
+    const mainHeader = document.querySelector('#pageTitle');
+    if (mainHeader) {
+      (mainHeader as HTMLElement)?.focus();
+    }
+  }
+
   /**
    * Indicators
    */
-- 
GitLab