diff --git a/src/Posting/Captcha.v2.coffee b/src/Posting/Captcha.v2.coffee index 3d993f805..6e8e67e53 100644 --- a/src/Posting/Captcha.v2.coffee +++ b/src/Posting/Captcha.v2.coffee @@ -245,9 +245,6 @@ Captcha.v2 = if $ 'iframe[src^="https://www.google.com/recaptcha/api2/frame"]', node new MutationObserver(@fixBubble.bind(@, node)).observe node, attributes: true - # Prevent Recaptcha from keeping focus when popup dismissed. - if (overlay = $ 'div[style*="position: fixed;"]', node) - $.on overlay, 'click', -> $('#qr iframe')?.blur() fixBubble: (node) -> {bottom, right, width} = node.getBoundingClientRect() diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index f72dc2ba2..c109d7b84 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -152,28 +152,12 @@ QR = unless QR.inBubble() QR.hasFocus = d.activeElement and QR.nodes.el.contains(d.activeElement) QR.nodes.el.classList.toggle 'focus', QR.hasFocus - # XXX Stop unwanted scrolling due to captcha. - if QR.captcha.isEnabled and QR.captcha is Captcha.v2 and !QR.captcha.noscript - if QR.inCaptcha() - QR.scrollY = window.scrollY - $.on d, 'scroll', QR.scrollLock - else - $.off d, 'scroll', QR.scrollLock inBubble: -> bubbles = $$ 'iframe[src^="https://www.google.com/recaptcha/api2/frame"]' d.activeElement in bubbles or bubbles.some (el) -> getComputedStyle(el).visibility isnt 'hidden' and el.getBoundingClientRect().bottom > 0 - inCaptcha: -> - (d.activeElement?.nodeName is 'IFRAME' and QR.nodes.el.contains(d.activeElement)) or (QR.hasFocus and QR.inBubble()) - - scrollLock: -> - if QR.inCaptcha() - window.scroll window.scrollX, QR.scrollY - else - $.off d, 'scroll', QR.scrollLock - hide: -> d.activeElement.blur() $.addClass QR.nodes.el, 'autohide' diff --git a/src/css/style.css b/src/css/style.css index d147f09f1..f2bced8b9 100644 --- a/src/css/style.css +++ b/src/css/style.css @@ -118,6 +118,10 @@ canvas#tegaki-canvas { body > div:last-of-type { transition: none !important; } +/* Fix captcha scrolling to top of page. */ +body > div[style*=" top: -10000px;"] { + visibility: hidden !important; +} /* Anti-autoplay */ audio.controls-added { @@ -1333,8 +1337,18 @@ input.field.tripped:not(:hover):not(:focus) { #qr .captcha-root { position: relative; } -#qr .captcha-container > div > div { +#qr .captcha-container > div { margin: auto; + width: 304px; +} +/* scrollable with scroll bar hidden; prevents scroll on space press */ +:root.blink #qr .captcha-container > div { + overflow: hidden; +} +:root.blink #qr .captcha-container > div > div:first-of-type { + overflow-y: scroll; + overflow-x: hidden; + padding-right: 15px; } #qr .captcha-counter { display: block;