Page MenuHomePhabricator

HTMLTagMultiselectField with 'dropdown' option and initially active 'hide-if' condition loses values
Closed, ResolvedPublicBUG REPORT

Description

Steps to reproduce: create form with

$multiselect = [
	'type' => 'multiselect',
	'options' => [ '1' => '1', '2' => '2' ],
	'required' => true,
	'default' => [ '1', '2' ]
];
$normal = [ 'label' => 'plain' ];
$dropdown = [ 'label' => 'dropdown', 'dropdown' => true, ];
$hidden = [ 'hide-if' => [ '===', 'hider', 'hide' ] ];
$form = HTMLForm::factory( 'ooui', [
	'hider' => [
		'type' => 'select',
		'options' => [ 'hide' => 'hide', 'show' => 'show' ],
		'default' => 'hide',
	],
	'plain' => $multiselect + $normal,
	'dropdown' => $multiselect + $dropdown,
	'plain-hidden' => $multiselect + $normal + $hidden,
	'dropdown-hidden' => $multiselect + $dropdown + $hidden,
], RequestContext::getMain() );
$form->setSubmitCallback( function ( $vals ) {
	var_dump( $vals );
	return true;
} );
$form->show();

Select "show" option in the dropdown, then submit.

Expected result: all fields will contain ['1', '2'].
Actual result: three of them will work but dropdown-hidden will be empty.

The bug does not occur when the form is submitted with the "hide" option selected (whether initially or by unhiding and re-hiding). Though that's probably because the form framework is ignoring the submitted value in favor of the default one.

Event Timeline

I'd guess this is the same underlying issue as T294186#7542705.

Change 796775 had a related patch set uploaded (by Func; author: Func):

[mediawiki/core@master] multiselect: Init the disable state of MenuTagMultiselectWidget

https://gerrit.wikimedia.org/r/796775

Change 796775 merged by jenkins-bot:

[mediawiki/core@master] multiselect: Init the disable state of MenuTagMultiselectWidget

https://gerrit.wikimedia.org/r/796775

matmarex assigned this task to Func.

Thanks for the quick fix, Func!