From 0b27107aeb430e138551bad2e9948100b570ece9 Mon Sep 17 00:00:00 2001 From: anapnoe <124302297+anapnoe@users.noreply.github.com> Date: Mon, 1 May 2023 12:46:28 +0300 Subject: [PATCH] fix Unable to resize the text boxes in extensions #100 --- javascript/ui.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/javascript/ui.js b/javascript/ui.js index 6ba4ffaf..7efca55e 100644 --- a/javascript/ui.js +++ b/javascript/ui.js @@ -320,7 +320,7 @@ onUiUpdate(function(){ /* auto grow textarea */ function autoGrowPromptTextarea(){ gradioApp().querySelectorAll('[id$="_prompt"] textarea').forEach(function (elem) { - elem.focus(); + elem.parentElement.click(); }); } @@ -332,10 +332,12 @@ onUiUpdate(function(){ e.target.style.minHeight = e.target.scrollHeight + offset + 2 + 'px'; }); - elem.addEventListener('focus', function (e) { - e.target.style.minHeight = 'auto'; - e.target.style.minHeight = e.target.scrollHeight + offset + 2 + 'px'; + elem.parentElement.addEventListener('click', function (e) { + let textarea = e.currentTarget.querySelector('textarea'); + textarea.style.minHeight = 'auto'; + textarea.style.minHeight = textarea.scrollHeight + offset + 2 + 'px'; }); + });