Allow text entry for chat to be more than 128 characters

Created on 15 April 2024, 7 months ago
Updated 21 May 2024, 6 months ago

Problem/Motivation

Currently users cannot enter more than 128 characters in the chat input field since Drupal has set a max length for this form type.

Steps to reproduce

Open the chat form and attempt to enter more than 128 characters.

Proposed resolution

Change the textfield input to a textarea input. Also provide functionality to allow the textarea to show as 1 line by default but then expand to additional lines as the user text reaches the end of each line.

User interface changes

Chat input field will change from textfield to textarea.

โœจ Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States RobbyMo

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @RobbyMo
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Vivek Panicker Kolkata

    Vivek Panicker โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Vivek Panicker Kolkata

    Inspiration taken from Autogrow textarea module.

  • Status changed to Needs review 7 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Vivek Panicker Kolkata

    Vivek Panicker โ†’ changed the visibility of the branch aws_bedrock_chat-3443827 to hidden.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States RobbyMo

    Thank you for providing an update for this Vivek! One thing that I ask that you add into your MR is the changes for the other references to the old input textfield.

    For example in aws_bedrock_chat.js:

    var userMessage = $('input.aws-bedrock-chat-user-input', context).val();

    In aws_bedrock_chat.css:

    .aws-bedrock-chat-input .form-type-textfield
    and
    .aws-bedrock-chat-input input.aws-bedrock-chat-user-input:focus

    In the ChatForm.php file when you change the 'user_input' #type to 'textarea' it now is resizable by the user. I would suggest adding the following to the 'user_input' form array to stop Drupal's default resizing capability on the the textarea:

    '#resizable' => 'none',

    Another thing that I noticed is that the textarea automatically expanded before it was necessary, I think it might be from function updateTextareaHeight() where you have textarea.style.height = ""; to reset the height. I think you might need to put in the explicit height there. Since you put 50px in the css, putting 50px here should reset it to the original height before determining if it needs to expand. This same reset will be needed after line 50 $('.aws-bedrock-chat-user-input', context).val(''); where the input is cleared after submission so that the textarea field returns to the default size after the message is sent.

    The other changes look good, just let me know if you have any questions, thanks!

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Vivek Panicker Kolkata

    Regarding setting resizable=>'none', there seems to be an existing CORE issue: https://www.drupal.org/project/drupal/issues/2787025 ๐Ÿ› Setting #resizable on a textarea has no effect Needs review .

    The issue was closed, but I re-opened it since it still exists.

    So adding the attribute from the backend is not having any effect, so I marked it resizble: false in the CSS.

    I have addressed the feedbacks you have mentioned and updated the MR.

  • Status changed to RTBC 7 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States RobbyMo
  • Status changed to Fixed 7 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States RobbyMo
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024