fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-04-11 08:10 am

[dw-free] options in dropdowns in customize are randomly ordered

[commit: http://hg.dwscoalition.org/dw-free/rev/d355b683e217]

http://bugs.dwscoalition.org/show_bug.cgi?id=3608

Don't mess with the ordering.

Patch by [personal profile] fu.

Files modified:
  • cgi-bin/LJ/Widget/S2PropGroup.pm
--------------------------------------------------------------------------------
diff -r 0bbacf3153c8 -r d355b683e217 cgi-bin/LJ/Widget/S2PropGroup.pm
--- a/cgi-bin/LJ/Widget/S2PropGroup.pm	Mon Apr 11 11:30:04 2011 +0800
+++ b/cgi-bin/LJ/Widget/S2PropGroup.pm	Mon Apr 11 16:10:23 2011 +0800
@@ -17,6 +17,7 @@ use base qw(LJ::Widget);
 use base qw(LJ::Widget);
 use Carp qw(croak);
 use LJ::Customize;
+use List::Util qw( first );
 
 sub authas { 1 }
 sub need_res { qw( stc/widgets/s2propgroup.css js/colorpicker.js stc/collapsible.css ) }
@@ -425,18 +426,18 @@ sub output_prop_element {
     } elsif ( $prop->{values} ) {
         $ret .= "<td class='prop-input'>" unless $is_group;
 
-        # take the list of allowed values
-        # and prepend custom values (set through the layer editor) if allowed
-        my %vals = split( /\|/, $prop->{values} );
-        $vals{$override} = "Custom: " . $override if $prop->{allow_other}
-                    && defined $override
-                    && ! $vals{$override};
+        # take the list of allowed values, determine whether we allow custom values
+        # and whether we have a value not in the list (possibly set through the layer editor)
+        # if so, prepend custom values
+        my @values = split( /\|/, $prop->{values} );
+        unshift @values, $override, "Custom: $override"
+            if $prop->{allow_other} && defined $override && ! first { $_ eq $override } @values;
 
         $ret .= $class->html_select(
             { name => $name,
               disabled => ! $can_use,
               selected => $override, },
-              %vals,
+              @values,
         );
         $ret .= " <label>" . LJ::eall( $prop->{des} ) . "</label>" if $is_group && $prop->{des};
         $ret .= "</td>" unless $is_group;
--------------------------------------------------------------------------------
ninetydegrees: Art & Text: heart with aroace colors, "you are loved" (Default)

[personal profile] ninetydegrees 2011-04-11 08:50 am (UTC)(link)
\o/ I noticed that and forgot to mention it. *hides*