Follow up - f54df50 - Fixes #3040: Prevent race condition between different focus events that are opening and instantly closing the reply input field.

This commit is contained in:
Mantas 2020-09-11 13:18:45 +03:00 committed by Thorsten Eckel
parent b310ee519d
commit 36a0fc98a6

View file

@ -60,7 +60,7 @@ class App.TicketZoomArticleNew extends App.Controller
@setArticleTypePre(data.type.name, data.signaturePosition) @setArticleTypePre(data.type.name, data.signaturePosition)
@openTextarea(null, true) @openTextarea(null, true, true)
for key, value of data.article for key, value of data.article
if key is 'body' if key is 'body'
@$("[data-name=\"#{key}\"]").html(value) @$("[data-name=\"#{key}\"]").html(value)
@ -78,8 +78,6 @@ class App.TicketZoomArticleNew extends App.Controller
if data.position is 'end' if data.position is 'end'
@placeCaretAtEnd(@textarea.get(0)) @placeCaretAtEnd(@textarea.get(0))
return return
@textarea.focus()
) )
# add article attachment # add article attachment
@ -92,6 +90,7 @@ class App.TicketZoomArticleNew extends App.Controller
# reset new article screen # reset new article screen
@bind('ui::ticket::taskReset', (data) => @bind('ui::ticket::taskReset', (data) =>
@releaseGlobalClickEvents()
return if data.ticket_id.toString() isnt @ticket_id.toString() return if data.ticket_id.toString() isnt @ticket_id.toString()
@type = 'note' @type = 'note'
@defaults = {} @defaults = {}
@ -498,12 +497,14 @@ class App.TicketZoomArticleNew extends App.Controller
value = "/#{App.User.find(@Session.get('id')).initials()}" value = "/#{App.User.find(@Session.get('id')).initials()}"
@signature.text(value) @signature.text(value)
openTextarea: (event, withoutAnimation) => openTextarea: (event, withoutAnimation, focus) =>
if event if event
event.stopPropagation() event.stopPropagation()
if @articleNewEdit.hasClass('is-open') if @articleNewEdit.hasClass('is-open')
return return
$(window).off('click.ticket-zoom-textarea')
duration = 300 duration = 300
if withoutAnimation if withoutAnimation
@ -517,7 +518,9 @@ class App.TicketZoomArticleNew extends App.Controller
options: options:
duration: duration duration: duration
easing: 'easeOutQuad' easing: 'easeOutQuad'
complete: => $(window).off('click.ticket-zoom-textarea').on('click.ticket-zoom-textarea', @closeTextarea) complete: =>
$(window).on('click.ticket-zoom-textarea', @closeTextarea)
@textarea.focus() if focus
@textBubble.velocity @textBubble.velocity
properties: properties: