From 49aba7193d53f9654666a51f72692d3412d4340e Mon Sep 17 00:00:00 2001 From: ralf Date: Fri, 5 Aug 2022 20:33:29 +0200 Subject: [PATCH] adapt tab-activation on validation error to new tabs and additionally scroll widget into view --- api/js/etemplate/etemplate2.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/api/js/etemplate/etemplate2.ts b/api/js/etemplate/etemplate2.ts index c389726980..d5e9061ee9 100644 --- a/api/js/etemplate/etemplate2.ts +++ b/api/js/etemplate/etemplate2.ts @@ -144,6 +144,7 @@ import './et2_widget_countdown'; import './et2_extension_nextmatch'; import './et2_extension_customfields'; import './vfsSelectUI'; +import {Et2Tabs} from "./Layout/Et2Tabs/Et2Tabs"; /** @@ -1590,14 +1591,19 @@ export class etemplate2 } // Handle validation_error (messages coming back from server as a response) if widget is children of a tabbox let tmpWidget = widget; - while(tmpWidget.getParent() && tmpWidget.getType() != 'tabbox') + while(tmpWidget.getParent() && tmpWidget.getType() !== 'ET2-TABBOX') { tmpWidget = tmpWidget.getParent(); } - //Acvtivate the tab where the widget with validation error is located - if(tmpWidget.getType() == 'tabbox') + //Activate the tab where the widget with validation error is located + if(tmpWidget.getType() === 'ET2-TABBOX') { - (tmpWidget).activateTab(widget); + (tmpWidget).activateTab(widget); + } + // scroll the widget into view + if (typeof widget.getDOMNode().scrollIntoView === 'function') + { + widget.scrollIntoView(); } } egw().debug("warn", "Validation errors", _response.data);