From 7ea27276b7b6f0185a4ebf3a9a342f7f51664a00 Mon Sep 17 00:00:00 2001 From: Bola Ahmed Buari Date: Wed, 7 Apr 2021 09:34:05 +0000 Subject: [PATCH] Fixes #3445: Admin sidebar scrolls up on click on translations menu --- .../app/controllers/translation.coffee | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/app/controllers/translation.coffee b/app/assets/javascripts/app/controllers/translation.coffee index 41e624d5f..ac631f9c0 100644 --- a/app/assets/javascripts/app/controllers/translation.coffee +++ b/app/assets/javascripts/app/controllers/translation.coffee @@ -5,6 +5,7 @@ class Translation extends App.ControllerSubContent 'click .js-pushChanges': 'pushChanges' 'click .js-resetChanges': 'resetChanges' 'click .js-syncChanges': 'syncChanges' + initialRenderingDone: false constructor: -> super @@ -38,6 +39,7 @@ class Translation extends App.ControllerSubContent url: "#{@apiPath}/translations/admin/lang/#{@locale}" processData: true success: (data, status, xhr) => + @initialRenderingDone = true @times = [] @stringsNotTranslated = [] @stringsTranslated = [] @@ -50,6 +52,8 @@ class Translation extends App.ControllerSubContent else @stringsTranslated.push item + @untranslatedAtLastRender = $.extend({}, App.i18n.getNotTranslated(@locale)) + if !@translationToDo || event is 'render' @translationToDo = new TranslationToDo( el: @$('.js-ToDo') @@ -80,12 +84,13 @@ class Translation extends App.ControllerSubContent ) show: => - # see https://github.com/zammad/zammad/issues/2056 - @untranslatedAtLastRender ||= $.extend({}, App.i18n.getNotTranslated(@locale)) - return if _.isEqual(@untranslatedAtLastRender, App.i18n.getNotTranslated(@locale)) + return if @initialRenderingDone is false - @untranslatedAtLastRender = $.extend({}, App.i18n.getNotTranslated(@locale)) - App.Event.trigger('ui:rerender') + # see https://github.com/zammad/zammad/issues/2056 + return if _.isEmpty(App.i18n.getNotTranslated(@locale)) + return if @untranslatedAtLastRender && _.isEqual(@untranslatedAtLastRender, App.i18n.getNotTranslated(@locale)) + + @render() hide: => @rerender()