-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Commit
In Firefox, hovering over an option in an open select menu updates the selected property of option elements. This means that when a render is triggered by the digest cycle, and the list of options is being rendered, the selected properties are reset to the values from the model and the option hovered over changes. This fix changes the code to only use DOM elements' selected properties in a comparison when a change event has been fired. Otherwise, the internal new and existing option arrays are used. Closes #2448 Closes #5994
- Loading branch information
There are no files selected for viewing
3 comments
on commit f40f54c
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.
Sorry but i don't really understand that test, maybe you can help me understand better
- you first manually change
option.property
of a non-selected option - then ensure the property is kept in the DOM, OK
- but then we make sure it's not really selected in the model ?
as angular rewrites all the properties based on the model value during digest, for me its legit that a non-selected option (B) (based on the model value) doesn't keep the selected property, nope ?
looks like this change introduces a bug in a special case on some browsers (iOS, IE) : when we have an ngModel that doesnt belong to ngOptions, angular adds an empty option, that is removed on selection. that changes introduces a shift in the index and thus the displayed value is not the selected one. the model value, though is OK
Here's an example you can try on iOS/IE : http://run.plnkr.co/plunks/xS3sDPIv7DnuxqA8A5bI/
Any idea ?
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.
@revolunet your issue that you bring up is a known issue, someone has been working on a fix for it but it's not clear that they've ever submitted it yet, if you want to try and work on that. It isn't super high priority at the moment, but we'd like to get that fixed.
However, and this is important, ng-model
throws a wrench into the whole "model -> view" thing. With ng-model
, we're basically saying that the view / user interactions have the ability to change the model, and different browsers do this sort of differently for select
controls. IE, before this patch was checked in, we had some issues on firefox, now after this patch is checked in, we have some issues on IE/iOS. Ideally, we don't have any of those issues. The web makes this hard, but that's what we're going for here. But yeah, the model does need to update to reflect changes to the selected state of options.
Anyways, if you are interested in working on a fix for the IE/iOS issue, that would be awesome
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.
thanks fo the feedback, i'm working on it, trying to sort out the select directive code which is not very easily readable :)
IMHO this issue should be a priority as a simple combination of an invalid ngModel (eg: empty value) with ngOptions is buggy on IE and all iOS which is quite a lot of browsers :/
this reverts what was done here : 4622af3
and cause a bug in iOS