From 36a0fc98a67812123b121b1065615e2f053ee86c Mon Sep 17 00:00:00 2001 From: Mantas Date: Fri, 11 Sep 2020 13:18:45 +0300 Subject: [PATCH] Follow up - f54df50 - Fixes #3040: Prevent race condition between different focus events that are opening and instantly closing the reply input field. --- .../app/controllers/ticket_zoom/article_new.coffee | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee index c69a58c27..2eaa18e1a 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee @@ -60,7 +60,7 @@ class App.TicketZoomArticleNew extends App.Controller @setArticleTypePre(data.type.name, data.signaturePosition) - @openTextarea(null, true) + @openTextarea(null, true, true) for key, value of data.article if key is 'body' @$("[data-name=\"#{key}\"]").html(value) @@ -78,8 +78,6 @@ class App.TicketZoomArticleNew extends App.Controller if data.position is 'end' @placeCaretAtEnd(@textarea.get(0)) return - - @textarea.focus() ) # add article attachment @@ -92,6 +90,7 @@ class App.TicketZoomArticleNew extends App.Controller # reset new article screen @bind('ui::ticket::taskReset', (data) => + @releaseGlobalClickEvents() return if data.ticket_id.toString() isnt @ticket_id.toString() @type = 'note' @defaults = {} @@ -498,12 +497,14 @@ class App.TicketZoomArticleNew extends App.Controller value = "/#{App.User.find(@Session.get('id')).initials()}" @signature.text(value) - openTextarea: (event, withoutAnimation) => + openTextarea: (event, withoutAnimation, focus) => if event event.stopPropagation() if @articleNewEdit.hasClass('is-open') return + $(window).off('click.ticket-zoom-textarea') + duration = 300 if withoutAnimation @@ -517,7 +518,9 @@ class App.TicketZoomArticleNew extends App.Controller options: duration: duration 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 properties: