Fixes #3445: Admin sidebar scrolls up on click on translations menu

This commit is contained in:
Bola Ahmed Buari 2021-04-07 09:34:05 +00:00 committed by Thorsten Eckel
parent fc61d799d5
commit 7ea27276b7

View file

@ -5,6 +5,7 @@ class Translation extends App.ControllerSubContent
'click .js-pushChanges': 'pushChanges' 'click .js-pushChanges': 'pushChanges'
'click .js-resetChanges': 'resetChanges' 'click .js-resetChanges': 'resetChanges'
'click .js-syncChanges': 'syncChanges' 'click .js-syncChanges': 'syncChanges'
initialRenderingDone: false
constructor: -> constructor: ->
super super
@ -38,6 +39,7 @@ class Translation extends App.ControllerSubContent
url: "#{@apiPath}/translations/admin/lang/#{@locale}" url: "#{@apiPath}/translations/admin/lang/#{@locale}"
processData: true processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
@initialRenderingDone = true
@times = [] @times = []
@stringsNotTranslated = [] @stringsNotTranslated = []
@stringsTranslated = [] @stringsTranslated = []
@ -50,6 +52,8 @@ class Translation extends App.ControllerSubContent
else else
@stringsTranslated.push item @stringsTranslated.push item
@untranslatedAtLastRender = $.extend({}, App.i18n.getNotTranslated(@locale))
if !@translationToDo || event is 'render' if !@translationToDo || event is 'render'
@translationToDo = new TranslationToDo( @translationToDo = new TranslationToDo(
el: @$('.js-ToDo') el: @$('.js-ToDo')
@ -80,12 +84,13 @@ class Translation extends App.ControllerSubContent
) )
show: => show: =>
# see https://github.com/zammad/zammad/issues/2056 return if @initialRenderingDone is false
@untranslatedAtLastRender ||= $.extend({}, App.i18n.getNotTranslated(@locale))
return if _.isEqual(@untranslatedAtLastRender, App.i18n.getNotTranslated(@locale))
@untranslatedAtLastRender = $.extend({}, App.i18n.getNotTranslated(@locale)) # see https://github.com/zammad/zammad/issues/2056
App.Event.trigger('ui:rerender') return if _.isEmpty(App.i18n.getNotTranslated(@locale))
return if @untranslatedAtLastRender && _.isEqual(@untranslatedAtLastRender, App.i18n.getNotTranslated(@locale))
@render()
hide: => hide: =>
@rerender() @rerender()