This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.5k
The placeholder (null option) in an ngSelect is broken in certain scenarios on IE9 #2150
Comments
Unfortunately this issue is a customer priority for us, so any form of workaround would also be appreciated. |
ghost
pushed a commit
to configit/angular.js
that referenced
this issue
Mar 15, 2013
Fixes a check inside render for select elements with ngOptions, which compares the selected property of an element with it's desired state. In instances where no element should be selected, this resulted in the first option in the select element having it's selected attribute set from undefined to false. In most browsers, this has the effect of displaying the first item in the list. In IE9 however, this causes the select to display nothing. In other browsers this would still cause unnecessary changes in selected state, but no visible issue would manifest. Closes angular#2150, angular#1826
ghost
pushed a commit
to configit/angular.js
that referenced
this issue
Mar 20, 2013
Fixes a check inside render for select elements with ngOptions, which compares the selected property of an element with it's desired state. Ensured the placeholder, if available, is explicitly selected if the model value can not be found in the option list. Without these fixes it's up to the browser implementation to decide which option to choose. In most browsers, this has the effect of displaying the first item in the list. In IE9 however, this causes the select to display nothing. Closes angular#2150, angular#1826
petebacondarwin
pushed a commit
that referenced
this issue
May 7, 2013
Fix a check inside render for select elements with ngOptions, which compares the selected property of an element with it's desired state. Ensure the placeholder, if available, is explicitly selected if the model value can not be found in the option list. Without these fixes it's up to the browser implementation to decide which option to choose. In most browsers, this has the effect of displaying the first item in the list. In IE9 however, this causes the select to display nothing. Closes #2150, #1826
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
None yet
0 participants
Browsers Tested
Chrome 25: 💚
Firefox 12: 💚
Firefox 19: 💚
IE8: 💚
IE9: 💥
IE10: 💚
Reproduction
http://jsfiddle.net/ySmah/2/
Details
The fiddle above demonstrates that in IE9, for 2 identical
<select>
elements withng-options
; settingng-required
on one of them causes the placeholder element to no longer be correctly selected.Inspecting the element shows that whilst
domElement.value
is "" in both cases,$(domElement).val()
isnull
in the broken example.I've tried to trace this in many ways but haven't been able to get any closer than this; Angular sets up the a directive for the following 'boolean' attributes
multiple,selected,checked,disabled,readOnly,required
. These directives are created with the name of the attribute, prefixed withng-
. These directives set up a watch to evaluate the value passed into them and callattr.$set(attributeName, !!value)
.Using any of these attributes causes the bug.
Update
Whilst the above neatly causes a reproduction, the root cause is more significant; any digest caused after the dropdown has rendered has the effect of wiping out the placeholder (as experienced here: #1826)
I've narrowed the cause of this down to a piece of code which causes a deselection of all options in the select. In most browsers unselecting the currently selected option causes the dropdown to revert to it's usual 'no option available' behavior, which is to implicitly select the first item; IE9 however will cause the dropdown to be blank.
I'm putting together a pull request now.
The text was updated successfully, but these errors were encountered: