Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indeterminate state not triggered #76

Open
kubijo opened this issue May 4, 2015 · 19 comments
Open

Indeterminate state not triggered #76

kubijo opened this issue May 4, 2015 · 19 comments
Assignees
Labels

Comments

@kubijo
Copy link

kubijo commented May 4, 2015

When the ng-model bound variable is undefined, it is said that the switch should be in indeterminate state - that however does not work. Below is link to plunker.

http://plnkr.co/edit/1SaSvTIzOeyjqWCl4GLH?p=preview

@frapontillo frapontillo added the bug label May 4, 2015
@frapontillo frapontillo self-assigned this May 4, 2015
@frapontillo
Copy link
Owner

Acknowledged, thanks for reporting this!

@kubijo
Copy link
Author

kubijo commented May 15, 2015

Hi. Do you have some estimation for the fix?

@frapontillo
Copy link
Owner

Sorry @kubijo, I have no idea when I'll be able to work on this. :(

@kubijo
Copy link
Author

kubijo commented May 15, 2015

I see. Well lets hope you'll get some time soonish. Thanks for reply.

@vanderlindenjc
Copy link

We are having the same issue, hope you can fix this soon.

@frapontillo
Copy link
Owner

Sorry for keeping you guys wait, the change is now available in the develop branch (also with angular-1.4.0 support).

@mirow
Copy link

mirow commented Aug 21, 2015

There is still the problem that the switch does not always come out of the indeterminate state when you click on it. You can see this in the same plunker:
http://plnkr.co/edit/1SaSvTIzOeyjqWCl4GLH?p=preview
To reproduce: set switch to 'ON', then click on "Toggle undefined", then click on the switch. The switch is now in the 'OFF' state, but the model value wasn't updated, it's still undefined.

@frapontillo
Copy link
Owner

@mirow you're right, I am going to reopen this.

@frapontillo frapontillo reopened this Aug 21, 2015
@mirow
Copy link

mirow commented Aug 26, 2015

I think you need to set the state to null when the state is indeterminate (as explained here: Bttstrp/bootstrap-switch#426 )

Maybe you could always set the state to null in the bootstrapSwitch constructor, and update the state in scope.$watch?

Also, currently you only check if the model value matches the true value, you don't check whether it matches the false value. Instead you should do something like this:

if (newValue === getTrueValue()) {
  element.bootstrapSwitch('state', true, false);
  element.bootstrapSwitch('toggleIndeterminate', false, true);
} else if (newValue === getFalseValue()) {
  element.bootstrapSwitch('state', false, false);
  element.bootstrapSwitch('toggleIndeterminate', false, true);
} else {
  element.bootstrapSwitch('state', null, false);
  element.bootstrapSwitch('toggleIndeterminate', true, true);
}

(This is actually to fix a slightly different bug: if the model value is undefined, then the switch is set to indeterminate state correctly. But if the model value is null, then the switch is set to 'false' state, no matter what the ng-false-value is.)

@frapontillo
Copy link
Owner

Can you try it with 0.5.0?

@adestis-ds
Copy link

In version 0.5.0 the switch is always in the state indeterminate - regardless of the model value!

@frapontillo
Copy link
Owner

@adestis-ds that's impossible, all tests pass and you can see that the behavior is correct at the demo in the first post.

@frapontillo
Copy link
Owner

Closing due to inactivity.

@skapin
Copy link

skapin commented Apr 25, 2016

Still buggy. When state is ON, then set model to NULL, then click the swiotch, the model is empty but visual state display OFF.

@jnicolau
Copy link

It's clearly not working. Lol... why was the issue closed.

@frapontillo
Copy link
Owner

@jnicolau then feel free to post a breaking sample.

@mirow
Copy link

mirow commented Aug 1, 2016

There's a new, slightly different, bug:
http://plnkr.co/edit/1SaSvTIzOeyjqWCl4GLH?p=preview
Set value to false, then click on "Toggle undefined". The visual state should become indeterminate, but it remains OFF.

@frapontillo
Copy link
Owner

So it is an issue related to switching from false to undefined.

@westerncj
Copy link

Are there any updates to this bug? When ng-model is set to undefined from a true state, it toggles to indeterminate. When it's set to undefined from a false state, indeterminate is not toggled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants