Page MenuHomePhabricator

Always show the checkbox when the boolean type is added in the template insert dialog
Open, MediumPublic

Description

From the ever-helpful 197.218 at https://www.mediawiki.org/wiki/Topic:Txpfe5vwkzu8j51x

The checkbox only appears if the template exists on a page with either value of 0 or 1.

Steps to reproduce:

  1. Create a template "testbool"
  2. Add the following to the template:
<noinclude><templatedata>
{
	"params": {
		
		"p1": {
			"type": "boolean"
		}
	}
}
</templatedata></noinclude>
test {{{p1}}}
  1. Go to test page
  2. Click insert template
  3. Insert "testbool"
  4. Add p1

Expected

A checkbox to select or deselect (or unset) a true / false parameter.

Actual

The interface presents a blank text box.

Proposed solution

Always show the checkbox with false as the default, and unset it (e.g.{{testbool}}) when the user
removes the parameter from the insert dialog

Alternate solutions

Add a new toggleswitch with the three states (on, off, unset (e.g. {{testbool|p1=}} or {{testbool}}) , e.g. http://www.jqueryscript.net/demo/jQuery-Plugin-For-Tri-state-Toggle-Switch-Candlestick/

Notes:

It was initially quite confusing that the value 1 or 0 must be set to see the checkbox. It took me quite a while to figure that out. Even setting the parameter default as 1 doesn't make the checkbox initially appear.

One benefit of the alternative solution is that this would also resolve the problem discussed in https://www.mediawiki.org/wiki/Topic:Tiazyrpyuav76l53.

Having a tri-state toggleswitch would allow users to remove the template parameter by setting it to the third state (undefined). This in turn could be interpreted as either :

{{testbool|p1=}}
Or

{{testbool}}

The first is probably best for the visual editor because it would differentiate between someone adding a parameter and leaving it undefined, and someone never adding that parameter. Although the second example would probably be preferred by editors.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Deskana moved this task from To Triage to Freezer on the VisualEditor board.

I agree the described behavior is weird. Luckily there is a very quick workaround: Add "autovalue": "0" to the parameter, then it behaves exactly as it should.