Page MenuHomePhabricator

Consider changing toggle to toggleVisibility
Open, MediumPublic

Event Timeline

Jdforrester-WMF raised the priority of this task from to High.
Jdforrester-WMF updated the task description. (Show Details)
Jdforrester-WMF added a project: OOUI.
Jdforrester-WMF moved this task to Backlog on the OOUI board.
Jdforrester-WMF changed Security from none to None.
Jdforrester-WMF subscribed.

I considered it and in my opinion .toggle() is intuitive enough, matches the convention established by jQuery and is a lot harder to mistype than .toggleVisibility(). ;) More considerations would be welcome.

Jdforrester-WMF lowered the priority of this task from High to Medium.Dec 6 2014, 11:18 PM
Jdforrester-WMF moved this task from Backlog to Next-up on the OOUI board.

The problem comes from something like ToggleSwitchWidget.

var switch = new ToggleSwitchWidget();
// Hides and shows
switch.toggle();
// Changes the value
switch.setValue( true );

You have to admit, that's a little awkward.

One of the things we currently have working against us here is our implementation of switches/checkboxes. In OOjs UI a checkbox or switch has a boolean value that relates to it's "selected" state, whereas HTML such fields have a value which is persistent no matter the sate and a separate "selected" property indicating the state. Not only does this mean we can't model HTML forms correctly at the moment, but it also means we run into this sort of confusion.

One of the things we currently have working against us here is our implementation of switches/checkboxes. In OOjs UI a checkbox or switch has a boolean value that relates to it's "selected" state, whereas HTML such fields have a value which is persistent no matter the sate and a separate "selected" property indicating the state. Not only does this mean we can't model HTML forms correctly at the moment, but it also means we run into this sort of confusion.

This is no longer true for checkboxes since T76645.

matmarex changed the task status from Open to Stalled.Dec 16 2014, 10:04 PM

I considered it and in my opinion .toggle() is intuitive enough, matches the convention established by jQuery

And now that we ditched jQuery's .toggle(), I'm starting to think that this could be worthwhile to prevent the two from being confused.

Aklapper changed the task status from Stalled to Open.May 30 2020, 12:40 PM

Boldly resetting task status after five years. This task should be either open (and valid), or declined (we are against doing this).