Make WordPress Core

Opened 7 years ago

Closed 3 months ago

#47445 closed enhancement (fixed)

Unable to set rows attribute for textarea input in the Customizer

Reported by: timhavinga's profile timhavinga Owned by: timothyblynjacobs's profile TimothyBlynJacobs
Milestone: 6.9 Priority: normal
Severity: normal Version: 5.2.1
Component: Customize Keywords: has-patch has-test-info
Focuses: ui Cc:

Description

Hi there,

Currently, when a textarea input is added to the Customizer via WP_Customize_Manager::add_control(), the number of rows is fixed to 5. See line 4140 of the Customize Manager.

Could this be fixed to be 5 by default, but enables me to override this?

Attachments (1)

47445.patch (843 bytes) - added by timhavinga 7 years ago.
Give custom control textareas 5 rows by default, but allow for a custom value

Download all attachments as: .zip

Change History (10)

@timhavinga
7 years ago

Give custom control textareas 5 rows by default, but allow for a custom value

#1 @timhavinga
7 years ago

  • Keywords has-patch added

#2 @timhavinga
7 years ago

As shown in my patch, the defect was not in class-wp-customize-manager.php, but in class-wp-customize-control.php. The code in the Customize Manager seems to do the right thing, though it is not clear to me when this function is called.

#3 @celloexpressions
5 years ago

  • Keywords needs-testing added
  • Milestone changed from Awaiting Review to Future Release

47445.patch makes sense to me, and allows the API to correctly let this attribute be set with the input_attrs property when registering a control. This needs some testing but looks close to being committable at a glance.

#4 @SirLouen
5 months ago

  • Keywords has-test-info added; needs-testing removed
  • Type changed from defect (bug) to enhancement

Test Report

Description

✅ This report validates whether the indicated patch works as expected.

Patch tested: https://core.trac.wordpress.org/attachment/ticket/47445/47445.patch

Environment

  • WordPress: 6.9-alpha-60093-src
  • PHP: 8.2.28
  • Server: nginx/1.29.0
  • Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
  • Browser: Chrome 137.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Twenty-One 2.5
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.0

Testing Instructions

  1. Add the code provided in Artifacts somewhere where it can be executed
  2. Go to the Customizer and select the new Menu
  3. Here we can see the customized Text Area rows.

Actual Results

  1. ✅ Issue resolved with patch:

https://i.imgur.com/AK74nmf.png

Additional Notes

  • To me, this looks more like an enhancement than a bug. Being aware that enhancements to Customizer have been halted as @celloexpressions commented a long time ago, this is a very straightforward patch that could be implemented with ease and maybe could serve some users for the last stretch of this component. At this point I think its an easy merge with tests that doesn't require much thinking.
  • ⚠️ Note that it only has a little PHPCS mistake

Supplemental Artifacts

Test Code

function customizer_textarea_sample( $wp_customize ) {
	$wp_customize->add_section(
		'customizer_textarea_sample_section',
		array(
			'title'    => __( 'Textarea Sample', 'customizer-textarea-example' ),
			'priority' => 10,
		)
	);

	$wp_customize->add_setting( 'simple_setting' );

	$wp_customize->add_control(
		'simple_setting',
		array(
			'label'   => __( 'Simple Textarea', 'customizer-textarea-example' ),
			'section' => 'customizer_textarea_sample_section',
			'type'    => 'textarea',
		)
	);

	$wp_customize->add_setting( 'large_setting' );

	$wp_customize->add_control(
		'large_setting',
		array(
			'label'       => __( 'Large Textarea', 'customizer-textarea-example' ),
			'section'     => 'customizer_textarea_sample_section',
			'type'        => 'textarea',
			'input_attrs' => array(
				'rows' => 10,
			),
		)
	);
}
add_action( 'customize_register', 'customizer_textarea_sample' ); 
Last edited 5 months ago by SirLouen (previous) (diff)

This ticket was mentioned in PR #9096 on WordPress/wordpress-develop by @SirLouen.


5 months ago
#5

Important

If this happens to be merged, docs should be updated
I'm adding this PR to also update docs (and fixing the PHPCS mistake in the original patch)

Trac ticket: https://core.trac.wordpress.org/ticket/47445

#6 @sabernhardt
5 months ago

  • Milestone changed from Future Release to 6.9

This ticket was mentioned in Slack in #core-test by sirlouen. View the logs.


5 months ago

#8 @sainathpoojary
5 months ago

Test Report

Description

This report confirms that the patch in PR #9096 correctly allows the rows attribute to be set via input_attrs for textarea controls in the Customizer. Previously, this was hardcoded to 5 rows.

Environment

  • WordPress: 6.9-alpha-60093-src
  • PHP: 8.2.28
  • Server: nginx/1.29.0
  • Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
  • Browser: Chrome 138.0.0.0
  • OS: macOS
  • Theme: Twenty Twelve 4.5
  • MU Plugins: None activated
  • Plugins:
    • Customizer Textarea Rows Test 1.0
    • Test Reports 1.2.0

Actual Results

✅ With the patch applied:

  • The Simple Textarea defaults to 5 rows.
  • The Large Textarea correctly displays 10 rows as defined in input_attrs.

This confirms that the patch resolves the issue and behaves as expected.

Additional Notes

Test plugin used to verify:
https://gist.github.com/SainathPoojary/81a6a49d43dbe47e008e903de094e412

Supplemental Artifacts

https://rioudcpuyg.ufs.sh/f/PL8E4NiPUWyOv2qJMTQjZPNB0iLXhnA3WpCIRmudgwDkV1Uc

#9 @TimothyBlynJacobs
3 months ago

  • Owner set to TimothyBlynJacobs
  • Resolution set to fixed
  • Status changed from new to closed

In 60662:

Customize: Allow specifying the number of rows for <textarea> inputs.

Previously, the textarea control was forced to use 5 rows. This commit instead applies a default value of 5, but allows for a developer to specify a different number of rows using the input_attrs arg.

Props sirlouen, timhavinga, celloexpressions, sainathpoojary.
Fixes #47445.

Note: See TracTickets for help on using tickets.