8000 fix(forms): disabled controls should never be invalid by kara · Pull Request #11257 · angular/angular · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(forms): disabled controls should never be invalid #11257

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

Merged
merged 1 commit into from
Sep 1, 2016

Conversation

kara
Copy link
Contributor
@kara kara commented Sep 1, 2016

We were running the disabled check too late, so sometimes individual controls that were instantiated as invalid and disabled were mistakenly calculated to be 'invalid'. The disabled status should always trump any other status.

@kara kara added the action: review The PR is still awaiting reviews from at least one requested reviewer label Sep 1, 2016
@vsavkin vsavkin added pr_state: LGTM and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Sep 1, 2016
@kara kara added action: merge The PR is ready for merge by the caretaker cla: yes labels Sep 1, 2016
@IgorMinar
Copy link
Contributor

@mprobst this one lgtm

@mprobst mprobst merged commit 043493c into angular:master Sep 1, 2016
@rgripper
Copy link
rgripper commented Sep 6, 2016

Is it somehow related to the case, when I disable all invalid controls form becomes valid as expected, but if I call control.updateValueAndValidity() after control.disable(), form.valid reports false? Moreover, after receiving status DISABLED through control.disable() controls magically transition to INVALID without triggering statusChanges.

@capi
Copy link
capi commented Sep 6, 2016

Will this also fix the case that calling disable() on a control makes the entire form invalid? Or should I open another issue for that?

I made a simple plnkr for that:
http://plnkr.co/edit/B8cA0zzcrt4SjxrGMlRf?p=preview

@kara
Copy link
Contributor Author
kara commented Sep 7, 2016

@rgripper Yes, the PR fixes that issue. If you npm install from the nightly build (angular/forms-builds), it should be resolved. Or you can wait for the next official release.

@capi The way the model works is that a parent form group is disabled if all its child controls are disabled. The status of group controls is always calculated as a reduction of the child controls. In your example, your form only has one form control. Once you disable it, you are effectively disabling the whole form because all its children are disabled. If you log the status of the form, you'll see that its status is 'DISABLED', which is why valid is false. The statuses are mutually exclusive.

@kara kara deleted the disabled-fix branch October 13, 2018 01:08
@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 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: forms cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0