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

MdCheckBox is behaving different to native checkbox #575

Closed
mmrath opened this issue May 29, 2016 · 9 comments
Closed

MdCheckBox is behaving different to native checkbox #575

mmrath opened this issue May 29, 2016 · 9 comments
Labels
P2 The issue is important to a large percentage of users, with a workaround
Milestone

Comments

@mmrath
Copy link

mmrath commented May 29, 2016

Bug, feature request, or proposal: Bug

Links for both native and MdCheckBox version below

What is the expected behavior?

Native Checkbox version
http://plnkr.co/edit/cZbFWOlCeZuj7YdUczPm?p=preview

What is the current behavior?

This is with MdCheckBox
http://plnkr.co/edit/FFpqdNhQfvbUynbPE1ZD?p=preview

What are the steps to reproduce?

  1. Click on the top select all check box for 'Write'
  2. Now click (reset) Write for one of the resource

Native version has the desired behaviour that is, unselect the top most checkbox if one of the below one is unchecked. But with MdCheckBox the change to reset top most checkbox triggers on change event, which is resetting all the below checkboxes.

I don't know which one is correct behaviour or both are correct.

Any help to get the MdCheckBox version working is appreciated.

What is the use-case or motivation for changing an existing behavior?

Get MdCheckBox behave as close to native checkbox as possible

Which versions of Angular, Material, OS, browsers are affected?

alpha 5

Is there anything else we should know?

Bo

@sendilkumarn
Copy link
Contributor

Interesting also, check this out

http://plnkr.co/edit/nDWK7EmmCBgMkHIKRIg7?p=preview

the checkbox click function is called twice, why so?

@zahlprish
Copy link

@sendilkumarn I have experienced the double fires since the last release (alpha 5).

@sendilkumarn
Copy link
Contributor

@jelbourn is this correct, I will submit a PR if so

Add a method for click event in checkbox. we can re use the checkbox change method itself. This kinda solves problem.

sendilkumarn added a commit to sendilkumarn/material2 that referenced this issue May 30, 2016
@jelbourn jelbourn added the P2 The issue is important to a large percentage of users, with a workaround label May 31, 2016
@jelbourn jelbourn added this to the alpha.6 milestone May 31, 2016
@jelbourn
Copy link
Member

jelbourn commented Jun 2, 2016

It seems that the issue here isn't a double-firing change, but is instead caused by different behavior between native inputs and our checkbox for when change events should be fired. Native inputs only fire a change event when they have user focus. The MdCheckbox fires a change event whenever it changes for any reason. I've actually had a note written about this to discuss with the rest of the team for a couple weeks now.

@sendilkumarn
Copy link
Contributor

Yeah agree to that. But clicks firing two times is also an issue. Check #613

Aim is to prevent double firing of click event

@sendilkumarn
Copy link
Contributor

one more weird behavior with respect to checkbox. Is this even correct or am I missing out anything.

click / change one - just printing ng model value => returns true / false
click / change two - just printing ng model value => returns MDCheckboxChange Object

is this expected?

@matthewdenobrega
Copy link
Contributor

matthewdenobrega commented Jun 16, 2016

I've set up a simple plunkr to demonstrate the duplicate events by logging to the console - http://embed.plnkr.co/3IGFLbFEpvVldtOOosAq/

On first click one change and two click events are fired.
On subsequent clicks two change and two click events are fired.

I'm having to set 10ms timeouts on all material inputs before reading model values from them - it would be great if they could update in the current digest cycle, but I presume the delays are there to avoid change after checked warnings.

@ImAllInNow
Copy link

I also have this issue where I'm getting an erroneous (changed) event to fire when the [ngModel] causes the checkbox to change from checked to unchecked. This behavior does not happen for md-input.

devversion added a commit to devversion/material2 that referenced this issue Jul 14, 2016
devversion added a commit to devversion/material2 that referenced this issue Jul 15, 2016
devversion added a commit to devversion/material2 that referenced this issue Jul 15, 2016
devversion added a commit to devversion/material2 that referenced this issue Jul 15, 2016
@kara kara closed this as completed in d52e6e0 Jul 15, 2016
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P2 The issue is important to a large percentage of users, with a workaround
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants