From fe8d9b6b4e42c38438858acf70a6074dd46fe603 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Mon, 17 Jul 2023 14:38:29 +0200 Subject: [PATCH] FIX: allows to focus thread's composer on ipad (#22639) On iOS we have a hack to prevent the viewport to move when focusing an input, however this code was targeting the textarea node through a global selector which is working fine on iOS as we only show one composer at a time but was failing on iPad as we show both channel and thread on the same screen. As a result `document.querySelector(".chat-composer__input")` was always targeting the first textarea on the screen which was the channel's composer, making it impossible to focus the thread's one. --- .../javascripts/discourse/components/chat-composer.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-composer.js b/plugins/chat/assets/javascripts/discourse/components/chat-composer.js index 304cd235719..0bb149018df 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-composer.js +++ b/plugins/chat/assets/javascripts/discourse/components/chat-composer.js @@ -276,9 +276,9 @@ export default class ChatComposer extends Component { return; } - // hack to prevent the whole viewport - // to move on focus input - textarea = document.querySelector(".chat-composer__input"); + // hack to prevent the whole viewport to move on focus input + // we need access to native node + textarea = this.composer.textarea.textarea; textarea.style.transform = "translateY(-99999px)"; textarea.focus(); window.requestAnimationFrame(() => {