From bbd9a56e428e72e1378cc292ec51b1820ef2ae7e Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 9 Sep 2026 13:29:32 +0200 Subject: [PATCH] Fix positional multi-select list compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ⓘ Preserve selected labels, value order and pre-escaped text when callers omit the options hash. --- t/ui-lib-widgets.t | 13 ++++++++++++- ui-lib.pl | 11 ++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/t/ui-lib-widgets.t b/t/ui-lib-widgets.t index 08d53a4da..161b7c751 100644 --- a/t/ui-lib-widgets.t +++ b/t/ui-lib-widgets.t @@ -509,6 +509,17 @@ like(main::ui_form_columns_table('x.cgi', [ [ 'go', 'Go' ] ], 0, undef, undef, is_deeply(\@disabled, [ 1, 0 ], 'themes receive the normalized disabled state'); } +# Three-argument callers retain legacy selected labels and order. +{ + my $values = [ [ 'b', 'Selected & saved' ], [ 'a', 'A' ] ]; + my $options = [ [ 'a', 'R&D' ], [ 'b', 'Available' ] ]; + my $html = main::ui_multi_select_list('short', $values, $options); + like($html, qr/name="short"[^>]*value="b\na"/, + 'omitting size preserves the supplied selection order'); + like($html, qr/>Selected & saved 3 && ref($opts) ne 'HASH'; +my $legacy = ref($opts) ne 'HASH'; if (ref($opts) ne 'HASH') { # Accept ui_multi_select's positional disabled argument. $opts = { 'disabled' => $_[5] };