-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(ngOptions): select disabled option when set from model #14233
Conversation
c83b4ba
to
d04cc68
Compare
@@ -2515,37 +2521,6 @@ describe('ngOptions', function() { | |||
expect(element.find('option')[1].selected).toBeTruthy(); | |||
}); | |||
|
|||
it('should not write disabled selections from model', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the duplicate test ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one :) It's a duplicate of https://github.com/angular/angular.js/pull/14233/files#diff-2cda0d7a6d8ec47da3560fbe59a634e3R850
Are you sure we don't need to also ignore Also, I can't decide if this is a BC or not ? Sure the new behavior seems more consistent and the old one was not documented, but still... |
Hmm ... readValue is called when the select changes, so on user input. At this point, the selected option shouldn't be disabled anyay, becasue the browser prevents selecting a disabeld option. So it's an additional check that would only come into play when someone selectes a disabled option programmtically and then triggers change. I think the check is okay. I'm fine with putting it into 1.6, but I also think that this is the expected behavior. I also don't think that anyone's application could break by showing the disabled value. The model is the same in both cases. |
@petebacondarwin wdyt, 1.5 / 1.4 or 1.6 with Breaking Change notice? |
AFAICT, So, this is just a hunch. And even if I proved correct, it would only affect some very cornery corner cases, so feel free to ignore. On the other hand, Theoretically thinking about it, the That's all too theoretical and minor though. I don't feel strongly either way. |
Given that this is really only a visual change let's put it in 1.5.x |
Please merge @Narretz |
When ngModel is set to a value that matches a disabled option, ngOptions will now select the option in the select element, which will set select.val() to the option hash value and visually show the option value / label as selected in the select box. Previously, disabled options forced the unknown value. The previous behavior is inconsistent with both default HTML behavior and select with ngModel but without ngOptions. Both allow disabled values to be selected programmatically. A common use case for this behavior is an option that was previously valid, but has been disabled, and cannot be selected again. This commit removes a duplicate test, and all other tests that previously checked that disabled options are not set have been adjusted to the ensure the opposite. Fixes angular#12756
d04cc68
to
3b05c48
Compare
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
bug fix
What is the current behavior? (You can also link to an open issue here)
See #12756
What is the new behavior (if this is a feature change)?
Does this PR introduce a breaking change?
Probably not, when we understand it as a bug fix.
Please check if the PR fulfills these requirements
Other information:
When a disabled option is set as the ngModel, ngOptions will now select the option
in the select element, which will set select.val() to the option hash value and visually
show the option value / label as selected in the select box. Previously, disabled
options forced the unknown value.
The previous behavior is inconsistent with both default HTML behavior and select with
ngModel but without ngOptions. Both allow disabled values to be selected programmatically.
Common use cases for this behavior include options that where previously valid, but have
been disabled, and cannot be selected again.
Fixes #12756