Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Bug. Select ng-options with multiple doesn't work IE10/11 when next to each other. #11314

Closed
wawyed opened this issue Mar 13, 2015 · 8 comments
Closed

Comments

@wawyed
Copy link

wawyed commented Mar 13, 2015

There seems to be an issue in IE10/11 using select with multiple attribute. The issue only seems to be happening when you have more than one select in a page. The unexpected behaviour renders all of the selects unresponsive minus the last one. It would appear to be a rendering issue, since if you toggle the visibility of the element it works as intended.

Here is a plnkr to reproduce the issue: http://plnkr.co/edit/E1asWesEj90OqAf5RIt2?p=preview

@Narretz
Copy link
Contributor

Narretz commented Mar 19, 2015

That was difficult to debug ...
Turns out IE(11) has a problem with this line where the label property is assigned:https://github.com/angular/angular.js/blob/v1.4.0-beta.6/src/ng/directive/ngOptions.js#L513

Previously, the whole template cloning / assigning was wrapped in jqlite. I guess we cannot simply skip the label assignment - theoretically it should be set to the text always, but I don't know if that works in all browsers.

The problem is that currently the bug appears regardless of which way the label is set: vanilla, $.prop, $.attr

@Narretz
Copy link
Contributor

Narretz commented Mar 24, 2015

This is a crazy bug. It only happens if the first select is wrapped in an element with display: blockor display: inline-block (possibly others).
It's also not possible to test this in a unit test with browserTrigger. I assume because the select is completely blocked to any user interaction, but browserTrigger dispatches the event directly from the DOM.

@chirayuk chirayuk modified the milestones: 1.4.0-rc.1, 1.4.0-rc.2 Apr 24, 2015
Narretz added a commit to Narretz/angular.js that referenced this issue May 3, 2015
If there are more than one select, and the first select is wrappend
in an element with display: inline or display: inline-block, all but
the last select are completely unresponsive to any user input.

This cannot be tested in a unit-test, as the events must come directly
from the ui.

Close angular#11314
@petebacondarwin petebacondarwin modified the milestones: 1.4.x - jaracimrman-existence, 1.4.0-rc.2 May 4, 2015
Narretz added a commit to Narretz/angular.js that referenced this issue Sep 21, 2015
If there is more than one select next to each other, and the first
select is wrappend in an element with display: inline or display: inline-block,
all but the last select are completely unresponsive to any user input.

This cannot be tested in a unit-test or e2e test.

Closes angular#11314
Closes angular#11795
@Narretz
Copy link
Contributor

Narretz commented Sep 22, 2015

The bug also appear in IE Edge. Here are two plnkrs that show how to repro the bug without angular, and two workarounds. Setting the option.label before the value works in IE9 too and will land in core. This was manually tested.

Narretz added a commit to Narretz/angular.js that referenced this issue Sep 22, 2015
If there is more than one select next to each other, and the first
select is wrappend in an element with display: inline or display: inline-block,
all but the last select are completely unresponsive to any user input.

This cannot be tested in a unit-test or e2e test.

Closes angular#11314
Closes angular#11795
Narretz added a commit to Narretz/angular.js that referenced this issue Sep 22, 2015
If there is more than one select next to each other, and the first
select is wrappend in an element with display: inline or display: inline-block,
all but the last select are completely unresponsive to any user input.

This cannot be tested in a unit-test or e2e test.

Closes angular#11314
Closes angular#11795
Narretz added a commit that referenced this issue Sep 22, 2015
In certain scenarios, IE10/11/Edge create unresponsive select elements.
The following contribute to the bug:
- There need to be at least 2 selects next to each other
- The option elements are added via javascript
- the option.value is accessed before it is set
- the option.label is added after the option.value has been set
- The first select is wrappend in an element with display: inline or
display: inline-block,

This cannot be tested in a unit-test or e2e test.

Closes #11314
Closes #11795
@mapurba
Copy link

mapurba commented Sep 25, 2017

I have a workaround for the IE picklist issue. which is not directly related with angular.
before Fix: http://plnkr.co/edit/NGwG1LUVk3ctGOsX15KI?p=preview
After Fix:http://plnkr.co/edit/NGwG1LUVk3ctGOsX15KI?p=preview
$("select").click(function(){ $(this).append('<option></option>'); $(this).find('option:last').remove(); });
I just added dummy option for the dom to rerender the select and removed it.
let me know it works for you

@petebacondarwin
Copy link
Contributor

@apurbamandal - is that a fix or a workaround?

@Narretz
Copy link
Contributor

Narretz commented Sep 25, 2017

This has been fixed in 42c97c5 and I just tested that it still works in 1.6.6 (it's not automatically testable unfortunately)

@mapurba
Copy link

mapurba commented Sep 25, 2017 via email

@Narretz
Copy link
Contributor

Narretz commented Sep 25, 2017

@apurbamandal You are right, this issue is not exclusive to AngularJS, but happens under specific circumstances when select options are added or manipulated with Javascript. In our case, it was caused by a combination of reading the option.value before setting it, and updating the option.label afterwards. It's not conclusive how this happens unfortunately (there might be other reasons).
Your solution is more of a workaround, as adding and removing an option element triggers a re-render of the select which unfreezes it. If this issue shows up when people google the problem it's ok to have it here, it's just important to point out that this is not a problem in AngularJS anymore.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.