Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#20879 closed defect (bug) (fixed)

Customizer: Add keyup events to sync textarea values.

Reported by: koopersmith Owned by: koopersmith
Milestone: 3.4 Priority: normal
Severity: normal Version: 3.4
Component: Customize Keywords: has-patch commit
Focuses: Cc:


We automatically sync text inputs with their js objects using keyup, but were not syncing for textarea. We should be doing both.

Attachments (2)

20879.diff (481 bytes) - added by koopersmith 9 years ago.
20879.2.diff (971 bytes) - added by koopersmith 9 years ago.

Download all attachments as: .zip

Change History (8)

9 years ago

#1 @koopersmith
9 years ago

Since we don't have any controls in core with textareas, here's an easy way to test the patch.

  1. Navigate to yoursite.com/wp-admin/customize.php
  2. Open up your browser's JS console.
  3. Drop this code block in the console:
    var textarea = jQuery('<textarea>').appendTo('#customize-theme-controls');
    var element = new wp.customize.Element( textarea );
    element.bind( function() {
    	console.log('element changed', arguments);
  4. Click inside the new textarea in the sidebar and type some text.
  5. Click somewhere outside of the textarea.

With the patch, you should see the value changing in the console as you type. Without the patch, you'll only see a change when you click out of the textarea (triggering a change event).

#2 @ocean90
9 years ago

Looks good.

#3 @azaozz
9 years ago

Typing "Enter" in the textarea is disabled (no new line) as Enter/Return is globally caught by $('#customize-controls').on( 'keydown',... L:575 in customize-controls.dev.js.

Perhaps exclude textareas by checking e.target there?

Last edited 9 years ago by azaozz (previous) (diff)

9 years ago

#4 @koopersmith
9 years ago

Good catch, Andrew. This patch should allow enter to be pressed in textareas.

#5 @azaozz
9 years ago

  • Keywords commit added

2.diff works well.

#6 @ryan
9 years ago

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

In [21024]:

Customizer: Add keyup events to sync textarea values. Props koopersmith. fixes #20879

Note: See TracTickets for help on using tickets.