From 27ee0fafd35a534d456469bbbc5936a34726dd63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Mon, 4 Dec 2017 11:10:27 +0100 Subject: [PATCH] Fix selection transformer focusing on element on each refresh (#6037) https://community.openproject.com/wp/26575 https://community.openproject.com/wp/26609 [ci skip] --- .../handlers/state/selection-transformer.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/frontend/app/components/wp-fast-table/handlers/state/selection-transformer.ts b/frontend/app/components/wp-fast-table/handlers/state/selection-transformer.ts index ca834642fa..6643219a49 100644 --- a/frontend/app/components/wp-fast-table/handlers/state/selection-transformer.ts +++ b/frontend/app/components/wp-fast-table/handlers/state/selection-transformer.ts @@ -12,6 +12,11 @@ export class SelectionTransformer { public states:States; public FocusHelper:any; + // When first entering the page, the user + // wants to scroll to the focused work package in the table. + // We only want to do this once, so remember when we did the first focus + private hasFocusedOnElement = false; + constructor(table:WorkPackageTable) { injectorBridge(this); @@ -24,10 +29,13 @@ export class SelectionTransformer { return; } - const element = locateTableRow(singleSelection); - if (element.length) { - element[0].scrollIntoView(); - this.FocusHelper.focusElement(element, true); + if (!this.hasFocusedOnElement) { + this.hasFocusedOnElement = true; + const element = locateTableRow(singleSelection); + if (element.length) { + element[0].scrollIntoView(); + this.FocusHelper.focusElement(element, true); + } } });