From ba1f466e8f2e142c3bc51e5bf864c2e4ba47dc28 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Wed, 25 Nov 2015 19:13:15 -0800 Subject: [PATCH] Fix captcha not refocusing when QR is autohidden and first try is wrong. #635 --- src/Posting/Captcha.v1.coffee | 4 +++- src/Posting/Captcha.v2.coffee | 6 +++++- src/Posting/QR.coffee | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Posting/Captcha.v1.coffee b/src/Posting/Captcha.v1.coffee index aa50aa354..5834893fb 100644 --- a/src/Posting/Captcha.v1.coffee +++ b/src/Posting/Captcha.v1.coffee @@ -95,7 +95,9 @@ Captcha.v1 = setup: (focus, force) -> return unless @isEnabled and (force or @needed()) @create() - @nodes.input.focus() if focus + if focus + $.addClass QR.nodes.el, 'focus' + @nodes.input.focus() afterSetup: -> return unless challenge = $.id 'recaptcha_challenge_field_holder' diff --git a/src/Posting/Captcha.v2.coffee b/src/Posting/Captcha.v2.coffee index 99bbe2cf2..5ea2af7e8 100644 --- a/src/Posting/Captcha.v2.coffee +++ b/src/Posting/Captcha.v2.coffee @@ -73,7 +73,11 @@ Captcha.v2 = setup: (focus, force) -> return unless @isEnabled and (@needed() or force) - @nodes.counter.focus() if focus + + if focus + $.addClass QR.nodes.el, 'focus' + @nodes.counter.focus() + if @timeouts.destroy clearTimeout @timeouts.destroy delete @timeouts.destroy diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 536a6aad7..41a22602c 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -769,7 +769,7 @@ QR = QR.cooldown.addDelay post, seconds else # stop auto-posting QR.cooldown.auto = false - QR.captcha.setup(QR.cooldown.auto and d.activeElement is QR.nodes.status) + QR.captcha.setup(QR.cooldown.auto and d.activeElement in [QR.nodes.status, d.body]) QR.cooldown.auto = false if QR.captcha.isEnabled and !QR.captcha.captchas.length QR.status() QR.error err