Problem/Motivation
Setting #resizable on a form element with #type => textarea has no effect.
According to the API docs https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21... setting the value to 'none' should disable the resizing. It does not.
Additionally, the default setting of "vertical" similarly has no effect - the area is sizable horizontally by default.
Tested in Chrome and Firefox.
Steps to reproduce
- Install vanilla Drupal 11.
- Create a custom form with a textarea (use
drush generate moduleanddrush generate formto quickly generate one with a textarea field as default). - Edit the form and set
#resizable => 'none'for the textarea. - Navigate to the form and notice the textarea is still resizable.
Proposed resolution
Set a resize-[mode] class on the textarea. These CSS classes already exist in core/modules/system/css/components/resize.module.css and the modes match the values for the CSS resize property.
Remaining tasks
- [X] - Add classes via attributes
- [X] - Tests
User interface changes
Resizable property will now behave as expected for textareas.
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | 2787025-nr-bot.txt | 2.16 KB | needs-review-queue-bot |
| #18 | With patch and parameter.png | 76.84 KB | danmer |
| #18 | Without patch and parameter.png | 61.08 KB | danmer |
| #18 | Drupal params.png | 117.84 KB | danmer |
| #9 | Screenshot from 2024-04-30 09-09-11.png | 275.51 KB | vivek panicker |
Issue fork drupal-2787025
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 11.x
compare
- 2787025-setting-resizable-on
changes, plain diff MR !7842
Comments
Comment #2
dfletcher commentedWhile looking for a fix, found out that the values for #resizable match the CSS 'resize' property values http://www.w3schools.com/cssref/css3_pr_resize.asp.
So perhaps template_preprocess_textarea() should add a class such as "resizable-none", "resizable-vertical", etc to the textarea tag. Unfortunately I'm still a bit of a Drupal 8 newbie so I'm not entirely sure where the CSS rules that set 'resize' property should actually live. Perhaps in classy or stable themes or both?
Comment #7
quietone commentedI testd this on Drupal 9.4.x, standard install, and resizable is working correctly, I tested all four options.
Closing as outdated.
Comment #8
vivek panicker commentedI confirm that this issue still exists on vanilla Drupal 11 install.
My system config is this:
I have generated a Drupal form using
drush gencommand which provides a text area by default.I just added `'#resizable' => 'none',` to it.
After doing that, the text area is still resizable.
Comment #9
vivek panicker commentedI did some debugging and found that the resizable argument is not sent to twig for the text area.

Comment #11
vivek panicker commentedI have raised an MR to fix the issue.
The Twig template seemed to have the variables defined in the docblock but were not using them.
I have added them now back to the code.
Comment #12
vivek panicker commentedComment #13
smustgrave commentedIssue summary should follow standard issue template.
Will need test coverage
That said I don't think this is the correct solution as it requires all these template types to be updated. Values should be added to attributes array in code so no templates need to be updated
Comment #14
vivek panicker commentedComment #15
vivek panicker commentedSeems like as part of https://www.drupal.org/project/drupal/issues/2407745, we have removed some code from the template but missed removing the documentation for it.
That's great actually, becuase that is what helped me to backtrace the changes.
Looks like these changes were done considering the classy theme but it is now breaking in newer versions of Drupal.
So should we revert the code instead to how it was here instead of how it has been done in the current MR?
Comment #17
vidorado commentedUpdated the MR and added a test
Comment #18
danmer commentedHello there, I have tested the issue according to the steps to reproduce.
My setup:
The patch fixes the issue; see attached screenshots
Comment #19
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #20
vidorado commentedRebased the MR onto latest 11.x branch and fixed a new PHPCS issue.
Comment #21
quietone commentedI read the IS, comments and the MR and didn't spot unanswered questions or other work. I updated credit.
Comment #23
catchThis is failing on phpcs after a rebase.
Comment #24
vidorado commentedFixed! Restoring to RTBC as it was only adding a docblock to a method.
Comment #26
catchCommitted/pushed to 11.x, thanks! Doesn't cherry-pick cleanly to 11.1.x.