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

  1. Install vanilla Drupal 11.
  2. Create a custom form with a textarea (use drush generate module and drush generate form to quickly generate one with a textarea field as default).
  3. Edit the form and set #resizable => 'none' for the textarea.
  4. 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

Issue fork drupal-2787025

Command icon 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:

Comments

dfletcher created an issue. See original summary.

dfletcher’s picture

While 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?

Version: 8.1.8 » 8.1.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

Version: 8.1.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Branches prior to 8.8.x are not supported, and Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
quietone’s picture

Status: Active » Closed (outdated)
Issue tags: -textarea +Bug Smash Initiative

I testd this on Drupal 9.4.x, standard install, and resizable is working correctly, I tested all four options.

Closing as outdated.

vivek panicker’s picture

Version: 9.3.x-dev » 11.x-dev
Assigned: Unassigned » vivek panicker
Priority: Normal » Major
Status: Closed (outdated) » Active

I confirm that this issue still exists on vanilla Drupal 11 install.
My system config is this: Only local images are allowed.

I have generated a Drupal form using drush gen command which provides a text area by default.
I just added `'#resizable' => 'none',` to it.
After doing that, the text area is still resizable.

vivek panicker’s picture

StatusFileSize
new275.51 KB

I did some debugging and found that the resizable argument is not sent to twig for the text area.
alt

vivek panicker’s picture

Assigned: vivek panicker » Unassigned

I 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.

vivek panicker’s picture

Status: Active » Needs review
smustgrave’s picture

Priority: Major » Normal
Status: Needs review » Needs work
Issue tags: +Needs issue summary update, +Needs tests

Issue 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

vivek panicker’s picture

Issue summary: View changes
vivek panicker’s picture

Seems 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?

vidorado made their first commit to this issue’s fork.

vidorado’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs issue summary update, -Needs tests

Updated the MR and added a test

danmer’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new117.84 KB
new61.08 KB
new76.84 KB

Hello there, I have tested the issue according to the steps to reproduce.
My setup:

Drupal Version: 11.2-dev
PHP Version: 8.3.14
Database Version: 10.11.10-MariaDB-ubu2204-log

The patch fixes the issue; see attached screenshots

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new2.16 KB

The 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.

vidorado’s picture

Status: Needs work » Reviewed & tested by the community

Rebased the MR onto latest 11.x branch and fixed a new PHPCS issue.

quietone’s picture

I read the IS, comments and the MR and didn't spot unanswered questions or other work. I updated credit.

catch made their first commit to this issue’s fork.

catch’s picture

Status: Reviewed & tested by the community » Needs work

This is failing on phpcs after a rebase.

vidorado’s picture

Status: Needs work » Reviewed & tested by the community

Fixed! Restoring to RTBC as it was only adding a docblock to a method.

  • catch committed e05b806d on 11.x
    Issue #2787025 by vidorado, vivek panicker, danmer, dfletcher,...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x, thanks! Doesn't cherry-pick cleanly to 11.1.x.

Status: Fixed » Closed (fixed)

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