I am experimenting with theming comments for Drulma and I noticed that the textarea display goes off screen because there is no template override.

I created a textarea.html.twig:

{#
/**
 * @file
 * Theme override for a 'textarea' #type form element.
 *
 * Available variables
 * - wrapper_attributes: A list of HTML attributes for the wrapper element.
 * - attributes: A list of HTML attributes for the textarea element.
 * - resizable: An indicator for whether the textarea is resizable.
 * - required: An indicator for whether the textarea is required.
 * - value: The textarea content.
 *
 * @see template_preprocess_textarea()
 */
#}
{%
  set classes = [
    'textarea',
    'form-textarea',
    'form-control',
    resizable ? 'resize-' ~ resizable,
    required ? 'required',
  ]
%}
<div{{ wrapper_attributes.addClass('form-textarea-wrapper','control') }}>
  <textarea{{ attributes.addClass(classes) }}>{{ value }}</textarea>
</div>

This is just the core template with an added textarea class for the textarea and control class for the wrapper div.

Textarea support is a necessity for many sites so I submit this for general inclusion into the theme.

CommentFileSizeAuthor
textarea_inside.PNG4.14 KBptmkenny
textarea_outside.PNG4.17 KBptmkenny

Comments

ptmkenny created an issue. See original summary.

rodrigoaguilera’s picture

Version: 8.x-1.6 » 8.x-1.x-dev
Status: Active » Fixed

This was in my todo list for a while since it is a basic element that was left without the Bulma styling.

The template override is a great approach but usually when is just two classes I prefer to use template_preprocess_textarea().
You can see the change here
https://gitlab.com/upstreamable/drulma/-/commit/fd1a1f9d4bd7d79a42b5d6a0...

Thank you for bringing this into my radar.

ptmkenny’s picture

Thanks, that's great! Yes, preprocess is a much more concise way to do this.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.