[wp-trac] [WordPress Trac] #31885: Widgets in Customizer fail to sync options in select[multiple]

WordPress Trac noreply at wordpress.org
Sat Apr 4 06:05:28 UTC 2015


#31885: Widgets in Customizer fail to sync options in select[multiple]
--------------------------+-------------------------
 Reporter:  westonruter   |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  4.2
Component:  Customize     |     Version:  3.9
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:  javascript
--------------------------+-------------------------
Description changed by westonruter:

Old description:

> When a widget is updated in the Customizer, the form values are
> serialized and sent via Ajax to pass through the widget's update
> callback. The widget form with the sanitized values is then sent in the
> Ajax response. The form inputs in the Ajax response are then copied over
> from the response into the existing form. This sync logic, however, does
> not account for the special case of `select[multiple]` inputs which lack
> a single `value` to synchronize: the value to synchronize is an array of
> zero or more values.
>
> The issue with synchronizing the `selected` state among a
> `select[multiple] option` elements is particularly evident when the
> widget's underlying setting is changed programmatically, as opposed to
> direct user input. Here is a demonstration of the issue by using a widget
> undo/redo feature: https://cloudup.com/cuSHMWiSgdM
>
> Big props to [https://github.com/davidlonjon davidlonjon] for discovering
> this issue and suggesting a fix.

New description:

 When a widget is updated in the Customizer, the form values are serialized
 and sent via Ajax to pass through the widget's update callback. The widget
 form with the sanitized values is then sent in the Ajax response. The form
 inputs in the Ajax response are then copied over from the response into
 the existing form. This sync logic, however, does not account for the
 special case of `select[multiple]` inputs which lack a single `value` to
 synchronize: the value to synchronize is an array of zero or more values.

 The issue with synchronizing the `selected` state among a
 `select[multiple] option` elements is particularly evident when the
 widget's underlying setting is changed programmatically, as opposed to
 direct user input. Here is a demonstration of the issue by using a widget
 undo/redo feature: https://cloudup.com/i7oo4v3X0v6

 Plugin used in demo is attached to ticket.

 Big props to [https://github.com/davidlonjon davidlonjon] for discovering
 this issue and suggesting a fix.

--

--
Ticket URL: <https://core.trac.wordpress.org/ticket/31885#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list